SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
filecopy to network share while run as a service

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
filecopy to network share while run as a service
Author Message
liangzhu



Joined: 30 Nov 2011
Posts: 42
Country: Singapore

Post filecopy to network share while run as a service Reply with quote
um, stupid/lazy question here...i'm using the windows version of 24x7 on win2003 server.

filecopy works fine while i was in gui mode. copying files to network shares.

but when i change 24x7 to run as a service, it doesn't work. (stupid here: i need to copy to a new folder everyday..the folders are named "dd-mm-yyyy". and there are different paths. on the first job of the day it will fail to create the new folder..i havent checked to see if it could copy to folders that already existed...)

lazy here:
how can i write to network shares while 24x7 is run as a service?

will mapping the drives first work? i.e. the drives are already mapped, then i use jal to filecopy to either the mapped drive letter\dd-mm-yyyy or still the same \\1.1.1.1\anywhere\dd-mm-yyyy.

or should i use runasuserandwait and give it a user account? what user acc should i give the command? does it have to be able to 'run as batch' locally and can also logon to the network share?

or should i use the runas tool in your tips&tricks archive? how is the runas tool different from the runasuserandwait function in jal? how about something like psexec?

or a really convoluted scheme where i use jal to write a bat using xcopy, then runandwait a 2nd bat that uses schtasks(will the service be able to run schtasks?) to run a schedule. then the schedule can run the bat that does the xcopy. an issue that may happen is runandwait will finish waiting as soon as the schedule is triggered. windows scheduler will return 0 when it successfully runs the task, not when the task finishes. and if the xcopy takes long enough, the jal will have looped and need to be writing the xcopy bat again...
Wed Dec 21, 2011 12:43 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7838

Post Reply with quote
Services and applications/jobs started from services cannot see mapped network shares – created in interactive sessions - this is by Windows design. Mapped shares are stored in a place in the system registry which is not accessible to the services.

A service either needs to create it's own mappings using NET.EXE USE ... command before using them (not recommended) or avoid referring to mapped drive names (recommended). In the last case, simply use UNC file names and share references in \\COMPUTER\SHARE\FILE name format. FileCopy and FileCopyEx support UNC names, just don't forget to properly escape backslash characters in path names, for example
in JAL: FileCopy( "c:\\folder\\myFile.txt", \\\\SomeServer\\SomeShare\\folder\\myFile.txt")
in JavaScript: file.Copy("c:\\folder\\myFile.txt", \\\\SomeServer\\SomeShare\\folder\\myFile.txt");
in VB, use FileSystemObject to copy files, which also supports UNC


Last edited by SysOp on Tue Dec 27, 2011 11:27 am; edited 1 time in total
Wed Dec 21, 2011 10:10 am View user's profile Send private message
liangzhu



Joined: 30 Nov 2011
Posts: 42
Country: Singapore

Post Reply with quote
Hi, i've been trying to get 24x7 , running as localsystem, in service mode, to runandwait

cmd /C net use \\\\192.168.1.31\\rje\\ password /USER:demo /PERSISTENT:No >> netuse.log

before that i find the time and write the time into netuse.log
and after that i copy a file from .31 to check that the net use is good.

this works when i run in gui.
but when i exit the gui and start the service, the log only gets the time, and no net use happened..

when i put the net use command onto a batch file and runandwait cmd /C to run the batch file, it also does not net use.

in the schedule.log i find that it says :
An error occurred while executing automation script: Line 18: Error copying file "\\192.168.1.31\rje\netuse.txt". Error: 5 - Access is denied.

then instead of running jal, i made the schedule run the batch file directly. and i gave the job the credentials that i log in as when i access the machine and successfully do everything in the gui mode. (if i gave 24x7 the same credentials to run as service(instead of localsystem), 24x7 is also able to net use using demo/password and copy files across shares successfully.)

now the schedule.log says:
Create process failed. Return code: 1314 - A required privilege is not held by the client.

so,
1. can 24x7, running as localsystem in service mode, ever copy files across network shares(if we give it a user/pwd)?
2. how do we give it a user/pwd?
3. what kind of privileges are needed and by who/what?
Tue Dec 27, 2011 4:13 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7838

Post Reply with quote
The "LocalSystem" account by default is blocked by Windows from accessing any network resources. That's why it is called local-system and that's the reason for "Error: 5 - Access is denied." You get that error from Windows, 24x7 records it in the log.

In addition, LocalSystem services are started before the network interface is loaded. When you do in the GUI mode, you already have them loaded

To allow a service start before anyone logs in to the system, and to allow access to the network, use either NetworkService account or domain admin account, or other similar account
Tue Dec 27, 2011 11:32 am View user's profile Send private message
liangzhu



Joined: 30 Nov 2011
Posts: 42
Country: Singapore

Post Reply with quote
1. sorry, but how do i make use of the NetworkService?

i'd like 24x7 to remain running as LocalSystem.

when i do this:
RunAsUserAndWait "cmd /C net use \\\\192.168.1.31\\rje password /USER:demo /PERSISTENT:No >> C:\\SFTP\\ABC\\SCRIPT\\Get_RPT\\TECHSFTPFILE\\Log\\netuse.log", "","0","NetworkService","","", nnetuse

or

RunAsUserAndWait "cmd /C net use \\\\192.168.1.31\\rje password /USER:demo /PERSISTENT:No >> C:\\SFTP\\ABC\\SCRIPT\\Get_RPT\\TECHSFTPFILE\\Log\\netuse.log", "","0","NetworkService","","NT AUTHORITY", nnetuse

i get return code 1326,logon failure, unknown user name or bad password.

2. and actually, if 24x7 were running as LocalSystem, and the net use was done as NetworkService, does it actually allow 24x7 to copy files across the network?

3. Or the solution is really to give 24x7 a user account with access to the network?
Tue Dec 27, 2011 11:15 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7838

Post Reply with quote
You cannot have both, Windows doesn't allow that. Please refer to Windows documentation for more details.
You cannot also use NetworkService for drive mapping or interactive or automated logins. Again, please refer to Windows documentation for more details.
Wed Dec 28, 2011 3:32 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.