How can I script schtasks so it doesn't need a password?

I'm trying to install some software using a batch script and using schtasks to start a service every day at midnight.

The script works fine, but it prompts for a password, which causes the script to hang. I've tried using the '/RU "user" /RP ""' flags, which seemed to work in XP, but not under Vista.

What is the right way to do this?


Solution 1:

If you understand the security implications*, you could run tasks with the local System account without a password.

SCHTASKS /Create /TN MyTask /TR "C:\MyTask.bat" /SC ONSTART /RU SYSTEM
SCHTASKS /Run /TN MyTask

This also works through the GUI, just enter SYSTEM as the user name and leave the password field blank.

*The biggest security risk would be someone changing the script or executable your scheduled task is pointed at. Be sure to set the file permissions accordingly.