Windows – Why is “start in” needed for Windows scheduled tasks

scheduled-taskwindows

We develop a web application that can be deployed on Windows or Linux. The Linux implementation uses cron, and the Windows one uses scheduled tasks to run a single PHP script that processes all scheduled tasks for our system.

The task is scheduled using schtasks during the install process, like:

This has always worked both under W2003 and W2008. A week ago a customer reported that scheduled tasks were not running. He is running on Windows 2008. We checked over and over and finally solved the issue by entering the folder that contains the .vbs script as the "start in" folder for the scheduled task.

This said, there is no way to set up the "start in…" value from schtasks without using an XML definition of the tasks. XML definitions don't work in Windows 2003, so I would have to add windows version detection to the installer, additional testing, etc (I'd like to avoid this if at all possible).

The only atypical thing I noticed about the install is that the system is installed in D:\ as opposed to the default C:\Program Files (x86)\, but I don't see how this would matter. All the paths are absolute in all the scripts.

Can anyone suggest a reasonable solution for this?

Best Answer

The "start in" is mainly to make sure that if you have relative paths in the task to run it understands which directory to run the script in.

That said, this link might help you: https://stackoverflow.com/questions/1020023/specifying-start-in-directory-in-schtasks-command-in-windows