5

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?

samoz
  • 1,943
  • 6
  • 18
  • 20

2 Answers2

4

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.

Nathan Hartley
  • 1,620
  • 5
  • 26
  • 38
  • You can further read about it here: http://technomosh.blogspot.com/2008/12/windows-scheduling-tip.html – Moshe Aug 04 '09 at 16:31
0

Have you tried /u and /p (without the R)?

From the help file:

/U username Specifies the user context under which the command should execute. /P password Specifies the password for the given user context.

Alternatively you could try using this utility to create a run as command for your task: http://www.robotronic.de/runasspc/