I have a scheduled task that is supposed to run a batch file. The batch files runs file when called on it's own, but does not run when wrapped in a scheduled task.
Here is what the dialog looks like:
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
In my case the solution was to replace the mapped drive with the fully qualified path. So instead of:
XCOPY C:\DATA Z:\ (where Z is the drive mapped to
I changed to:
XCOPY C:\DATA \\SERVER\DATA$
I run the task as Administrator and it worked like a charm.
If you are trying to copy these folders to a network share, it will not work because the scheduled task is run as 'System'. If this is the case, you have to specify which user the task is Run As.
NET USE B: \\remote-machine\location RemotePassword /user:remote-machine\RemoteUserName robocopy.exe B:\ D:\backups /NP /LOG+:D:\robocopy\robocopy.log /R:10 /W:5
This script maps the remote location to the network drive B: using the specified username and password for the remote machine.
Robocopy then copies the contents of the folder on the network location to the D:\backups folder. This will also log details to the specified robocopy log file so you can see how many files have been copied etc.
It guess. But high possible. Execution of .bat or .cmd really imply execution of cmd.exe In Windows for some (I think security) reasons, cmd.exe os executable only for interactive user. So it only can be executed when user logged in locally.
Give some group right to execute cmd.exe as sheduled task and assign user from whom executing this task to this group.