Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

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

share|improve this answer

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.

share|improve this answer
    
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 Dec 30 '09 at 4:41

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
share|improve this answer
    
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. –  ArmoredCAvalry Nov 9 '09 at 23:45
    
what about at ? –  John T Nov 9 '09 at 23:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.