Problem running a batch file with Scheduled Tasks or at cmd

P

Peter Chisholm

Cannot run a simple xcopy batch file within Windows 2000
Task Scheduler or as an AT CMD.

If I launch the batch file manually it works fine.

The batch file is "xcopy c:\docume~1\localu~1\mydocu~1\*.*
f:\backup /s /y".

Any ideas would be very welcome.


Regards

Peter Chisholm
 
J

Jerold Schulman

Cannot run a simple xcopy batch file within Windows 2000
Task Scheduler or as an AT CMD.

If I launch the batch file manually it works fine.

The batch file is "xcopy c:\docume~1\localu~1\mydocu~1\*.*
f:\backup /s /y".

Any ideas would be very welcome.


Regards

Peter Chisholm


The proper syntax is:

xcopy "c:\docume~1\localu~1\mydocu~1\*.*" f:\backup /s /y

though I would use the real long file names.



Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
M

Matt Hickman

Peter Chisholm said:
Cannot run a simple xcopy batch file within Windows 2000
Task Scheduler or as an AT CMD.

If I launch the batch file manually it works fine.


Could be a rights issue. Have you checked the Scheduled tasks log?
(advanced -> view log). Redirecting stderr from the batch file into a
file when it is run by the scheduler or at.exe?

Try using the "Run as" property for the scheduled task and
put in an ID with sufficient rights. The credentials for commands
run by at.exe and the task scheduler are not your user credentials
and usually those rights do not extend beyond the local computer.
 
A

Al Dunbar [MS-MVP]

Peter Chisholm said:
Cannot run a simple xcopy batch file within Windows 2000
Task Scheduler or as an AT CMD.

If I launch the batch file manually it works fine.

The batch file is "xcopy c:\docume~1\localu~1\mydocu~1\*.*
f:\backup /s /y".

That is not a batch file, that is a command.

/Al
 
A

Al Dunbar [MS-MVP]

Jerold Schulman said:
The proper syntax is:

xcopy "c:\docume~1\localu~1\mydocu~1\*.*" f:\backup /s /y

though I would use the real long file names.

I suspect that he quoted the entire command line just to show what it was,
exactly. Note that he says that if he launches the batch file manually it
works fine. Obviously when he launches it manually, he is not using the
double quotes, as that would fail in that context. Most likely he is quoting
it in the AT command, because that is the syntax for AT.

I agree that one should avoid using 8.3 filenames, as these may differ from
workstation to workstation. He would then need to include doubled
double-quotes in the AT command, i.e.:

AT ... "xcopy ""C:\documents and settings\localusername\my
documents\*.*"" F:\backup /s/y"

Matt is probably correct about this being a rights issue. If F: is not a
local drive, but a network drive, that could be an issue as well, as
suggested by Bob.

/Al
 
N

Ndi

I'd put it all in a .cmd file that runs from anywhere, like

%SystemRoot%\XCopy.exe "c:\docume~1\localu~1\mydocu~1\*" F:\

Note
+ using the environment to make it run from anywhere.
+ you should use the long names, in a quoted string: "C:\Documents and
settings\ ..."
+ you should use * instead of *.*, as that requires them to have a dot, and
not all do. Settings affect this behaviour.
+ schedule the batch, not the command: %comspec% /k "C:\MyBat.bat"

Scheduler has trouble launching .cmd or .bat files, for some reason (mp3
files start just fine?). Scheduling the command interpreter instead does it.
Once it works, schedule it using /c instead of /k, since the command window
will remain open, logged on as SYSTEM.

Alternately, do check the permissions. Schedule cmd.exe to run from
Scheduler (AT), you will be logged as SYSTEM. (echo %username%). Once there,
try to execute the command, see where if fails.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top