Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 want to use the runas command in CMD and from Batch files to gain elevated permissions, but I don't have an admin password on my PC because it's my home computer and I'm the only user. Every time I try to use the runas command it asks me for a password, then tells me that blank passwords are not permitted, is there any way round this? I know I can just right click and select run as administrator, but I would much rather have a command that can do it as that is not always an option, and it's just a bit of a pain.

I could just be making some kind of basic mistake as I'm not hugely experienced with command prompt, but I'm not completely clueless.

share|improve this question

Since this is a home environment, I'm slightly less nervous about this answer. You should read the notes in the policy I am going to mention to understand what the implications are.

Go to Start | Run. Type secpol.msc and press Enter. Navigate to Local Policies, then Security Options. Find the policy that says Limit local account use of blank passwords to console logon only. Set it to disabled.

share|improve this answer
+1 for not telling them to simply disable UAC. At least they're leaving it enabled! – Mark Allen Sep 5 '12 at 21:28

You can use VBScript to elevate commands:

Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "cmd.exe", "", "", "runas", 1 

Save as a *.vbs and then launch it with cscript or wscript

share|improve this answer
Nice trick. get +1 – Jet Mar 28 '14 at 15:01

I believe you can use SysInternal's PSexec.exe to force elevation.

You could try for example running this: psexec \\%computername% -i -h notepad.exe

share|improve this answer
Nice trick. Also it will work without that last "1" parameter. – Jet Mar 28 '14 at 16:03
That's a lowercase 'I' not a 1, it forces whatever you're executing to run Interactively, otherwise it likes to run in a headless session and you're left disappointed wondering where the heck your notepad went. :) (Been there, done that.) It very well might not be necessary when you're running it against the machine you're logged into, I haven't tried. – Mark Allen Sep 12 '14 at 18:08

As you've discovered, runas doesn't let you run a command elevated, only as a different user.

Elevation happens when you're try to start an executable that's been marked as requiring elevation, causing the UAC prompt. It's not just an option on CreateProcess. So if you're running non-elevated copy of cmd and want it to run another ordinary command but have it run elevated, you need an interlude command that can run it for you but is marked for elevation. It's complicated by the fact that current directories and environment variables don't get inherited by the elevated child.

The su command I included with my Hamilton C shell (full disclosure: I'm the author) has a sudo option that solves this and here's how I did it: When you ask su to run a command elevated, it starts a copy of itself stored as elevate.exe that's marked for elevation. elevate then handshakes through shared memory with su to pass the command line arguments, current directories and environment across the elevation boundary and then elevate runs the command.

share|improve this answer

I ran across RunAsSpc that will perform the RunAs command, but include the ability to read/write with an encrypted so your password is not exposed.

Author states these requirements are met by using RunAsSpc

  • The user does not have to enter a password, like runas.
  • Only the applications allowed by me, could be started by the user.
  • The tool must not be bypassed by simple renaming the application name or saving of identification (e.g. runas /savecred)
  • It should be simple to handle.
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .