2

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?

3 Answers 3

2

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"
3
  • T is for Tuesday
    – MDMarra
    Oct 6, 2009 at 18:12
  • Yes, and Th is for Thursday.
    – Ben S
    Oct 6, 2009 at 18:42
  • 1
    what about doing that every day? or two days for that matter?
    – bks
    Oct 6, 2009 at 20:46
0

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.
2
  • Even in XP, any batch file in a path on your PATH should be found.
    – Phoshi
    Oct 6, 2009 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, 2009 at 4:49
0

After looking at several related answers on SuperUser.com, and not wanting to use a workaround, I finally found the answer on StackOverflow here: https://stackoverflow.com/a/13173752/261405

The important piece from there: At the 'Action' settings - "Start in (Optional)" option.

Without this, it would never work for me

You must log in to answer this question.

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