Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to run a .bat file in Windows task scheduler, so I opened it, added a new task, browsed to the bat file, and... nothing happened.

So I changed the timing to see if it'll run, and it didn't. Next I right-clicked on the task and chose "run", it didn't run. The file itself is only one line, basicly backups a folder to a another location. It runs fine when not in the scheduler.

When I asked on stackoverflow.com they first said to come here and the other guy said to write:

cmd.exe /C completepathtobatchfile argstobatchfileifany

So I wrote:

cmd.exe /C k:\backup.bat 

and it didn't work. What do I have to change to make it work?

share|improve this question
up vote 2 down vote accepted

I find it easier to just use the at command.

For example to run the batch file located at: C:\script.bat at 4 AM every Tuesday you would do the following in a command-prompt:

at 4:00 /every:T "C:\script.bat"
share|improve this answer
    
works great! thanks mate what does the ":T" do? – bks Oct 6 '09 at 18:07
    
T is for Tuesday – MDMarra Oct 6 '09 at 18:12
    
Yes, and Th is for Thursday. – Ben S Oct 6 '09 at 18:42
    
what about doing that every day? or two days for that matter? – bks Oct 6 '09 at 20:46

Two things:

  1. I believe that in XP a batch file must use full pathnames, e.g. "C:\utility\file.exe" instead of just "filename.exe". The batch file run from the scheduler does not necessarily have a PATH or a current directory. That's for executables and targets both.
  2. Also, in XP I believe that filenames are limited to the old DOS-style 8+3 system. Try reducing filename (and directory name) lengths to the short version.
share|improve this answer
    
Even in XP, any batch file in a path on your PATH should be found. – Phoshi Oct 6 '09 at 18:05
    
I was referring to using full paths INSIDE the batch file, not necessarily the path TO the batch file. – CarlF Oct 7 '09 at 4:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .