Task scheduling Batch Files in Vista

3

Wondering if there is some trick to scheduling a batch file to run in Vista.

I have tried almost every setting/arg I can think of with no result other than an error, or the command window opening then instantly closing without executing the code.

The batch files works fine when I double click to run.

ArmoredCAvalry

Posted 2009-11-09T22:46:17.313

Reputation:

Answers

3

I figured out the issue.

If you have a batch file you want to run, the path to the batch file can not have any spaces in it (even if you include quotes).

Putting the batch file in C:\ allowed it to run via Task Scheduler.

ArmoredCavalry

Posted 2009-11-09T22:46:17.313

Reputation:

Sounds weird. I know the scheduler dialog is rather stupid like you should include quotes in the script path (browse:able) but exclude the quotes for the "start in" field... – Oskar Duveborn – 2009-12-30T04:41:33.263

2

Does the task scheduler in control panel not work?

You can also use at from the command line. If you want your script to be interactive and be visible to the user, you can use the /interactive switch:

at 20:00 /interactive c:\path\to\somefile.bat

this will open the command prompt at 8pm.

For finer control over the scheduling you can use schtasks:

SCHTASKS /Create /SC MONTHLY /MO first /D SUN /TN game /TR c:\windows\system32\freecell

John T

Posted 2009-11-09T22:46:17.313

Reputation: 149 037

yes, the default task scheduler does not work.

using schtasks, I still get the same issue, where the command prompt simply opens then closes without executing the batch commands. – None – 2009-11-09T23:45:12.407

what about at ? – John T – 2009-11-09T23:59:19.227

0

To work around this problem, enclose the path portion of the task (not including arguments or switches) between backslash (\) and quotation marks (") character combinations, for example \". Enclose the complete path of the task (including arguments or switches) between quotation marks as usual when you create a path or command that contains spaces.

schtasks /create /tn "my task" /tr "\"c:\foldername name containing spaces\script.bat\" arguments" /sc once /sd 07/29/2003 /st 10:01

source: support.microsoft.com

fluxtendu

Posted 2009-11-09T22:46:17.313

Reputation: 6 701