Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to write a script which includes disk defragmentation as one of its steps. defrag needs administrative rights to work. I tried to use runas /user:Administrator, but it always asked me for password (even though there isn't one set).

The script needs to run unattended for a long time, and it needs to be started from standard user account (it is actually being run by cygwin), so I'd like to get rid of that prompt. Is this possible?


share|improve this question

Right click cmd.exe and "Run as administrator". Call the script from inside the command line. The command line prompt's window title will be: Administrator: C:\Windows\System32\cmd.exe

share|improve this answer
Most of that script don't need admin rights, so I'd like to avoid running full script with full privileges. – liori Jun 28 '10 at 20:33
@liori Yet defrag NEEDS to be run as administrator, there's no other way if you want to avoid retyping your password every time. – BloodPhilia Jun 28 '10 at 20:35
On Linux I can give user rights to run specific command as another user using sudo. Microsoft says Windows is superior to Linux, so there must be a way to do that :-) – liori Jun 28 '10 at 20:41
Perhaps this is something for you: OR – BloodPhilia Jun 28 '10 at 20:43
I assumed there is something that doesn't require installing 3rd party software, like in a typical Linux installation... – liori Jun 28 '10 at 20:49

You should be able to use

 Runas /savecred /User:Administrator ...

This should only ask for the password the first time.

However, it is possible that this may fail if there is no password set, which means you may have to set one, or create another admin account with a password.

share|improve this answer

Your Answer


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.