Reputation: 1275
I don't generally write batches
, but I currently have a batch
that uses forfiles
to copy my FLVs from one folder to another. When I run the batch manually it works every time, but from a scheduled task, it throws a (0x1)
error.
forfiles -p "C:\Program Files\Adobe\Flash Media Server 4.5\applications\name\streams" -m *.flv -s -d -1 -c "cmd /c copy @file ^0x22C:\Program^ Files\Adobe\Flash^ Media^ Server^ 4.5\applications\name\output\"
Not sure what syntax the scheduled task doesn't like.
Update
Under my scheduled task, Actions I have the following:
Program/script: name.bat
Start in (optional): \\servername\file\to\batch
Upvotes: 6
Views: 90248
Reputation: 879
Hi might be this is helpful, I also face the same issue. Just set the startin path like:
Here start in path is the path of batch file: like you have enter in program script: "E:\program related files\demo.bat" then in startin just pass: E:\program related files & done!
Upvotes: 10
Reputation: 2472
For .bat files to run inside your scheduled task, you need to specify your .bat file path inside the start option - despite the fact that your .bat file is at the same directory as your .exe. Also, I flagged it to run with highest privilege. After I have done those two things, the task suddenly takes off without any problem!
Upvotes: 0
Reputation: 1237
See the screen shot bellow.
You need to change the user to system
Upvotes: 1
Reputation: 29
On Server 2008 R2 when running the batch file under domain user credentials, with confirmed "log on as a batch job" security in the Local Security Policy>Local Settings>User Rights Assignment, even then my batch (copying a log file to a network share) would not run as scheduled task, until I selected in tab General the option "Run with highest privileges" (default NOT checked!) The option Run whether user is logged on or not was also selected, with radio-button, but I guess this is quite standard, when selecting to run the task using a domain user account.
For the tab Actions : specifying the entire batch file name including its path, directly in "Program/script:" works fine (with Server 2008 R2) Using double quotes inside the batch file causes no problems.
Upvotes: 1
Reputation: 2887
I know this is an old question, but just wanted to share some info.
The (0x01) error code can also refer to resources that are not found. Therefore:
Upvotes: 0
Reputation: 1275
When my Start in (optional):
path was a UNC path, it wouldn't work. So I moved my batch on the server and everything worked correctly.
Upvotes: 3
Reputation: 3353
Most common reason for such problems is permissions: scheduled tasks does NOT always run with your user credentials. If you want scheduled task to run as you you will have to set it up as you or alternative user.
Besides that I hope that your line of code is a content of your batch file, you are not trying to run this command directly. Or are you?
P.S. What are these ^0x22
and ^
doing in your code?
Upvotes: 0