Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.

share|improve this answer
    
You can further read about it here: technomosh.blogspot.com/2008/12/windows-scheduling-tip.html –  Moshe Aug 4 '09 at 16:31

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/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.