views:

176

answers:

1

Hello everyone,

I have created a Windows 7 scheduled task:

schtasks /create /tn MyTask /tr C:\temp\test\MyScript.bat /sc MINUTE

Problem is that this task seems to get executed by Windows but I think it can not find the running BAT script. There is a quick flash window but can't read what the problem is.

On the other hand, if I place the script under Windows/System32 everything works fine.

schtasks /create /tn MyTask /tr C:\windows\system32\MyScript.bat /sc MINUTE

Anyone knows why the second schedule task works compared to the first one?

This whole thing is part of installing a program on a windows machine from a web page. So I would like to have the BAT file installed in its correct directory and not the System32.

Thanks for you help.

A: 

C:\temp is a temporary directory may be cleaned by the OS periodically. So you should first check to make sure that batch file is actually there, and then consider moving it to a more permanent location.

Second, have you tried running the task manually from its intended location? That should help you see what the output is. You can also add PAUSE to the bottom of the batch file (as suggested by commenters) to ensure that it stays up long enough for you to see the output.

Some likely problems are:

  • You're using some resource which is in %windir% via a relative path, which won't work when the batch file is run from a different location.
  • The scheduled task is running as a different user and doesn't have the proper permissions.
  • The task is doing something that requires elevation, but the task itself is not set to run elevated.
JSBangs