Is there any particular reason you're trying to do this from the command-line as opposed to built-in features available in the UI? Also, might there be a system policy that's preventing you from performing these operations?
Here's a suggestion using the UI:
- Open the Start Menu
- In the Search Bar, type
appwiz.cpl
.
- Wait for
appwiz.cpl
to appear in the search results. There should be only one entry at the top, under "Programs". It should have a document icon with some gears on it, and should be automatically highlighted.
- With
appwiz.cpl
highlighted in the search results, press CTRL+SHIFT+ENTER. This will force Windows to attempt executing appwiz.cpl
with Administrator privileges.
- Respond to any UAC prompts as appropriate.
If the above does not work, there may be an issue with your system's Security Policy. Do the following to check:
- Log into the system under an account that has Administrator permissions.
- Press Win+R.
- Type
secpol.msc
and hit ENTER.
- Respond to any UAC prompts as appropriate.
- In the left pane, navigate the tree to the following location:
Security Settings\Local Policies\Security Options
- Find the "User Account Control" options, near the bottom of the list.
- Check the setting
User Account Control: Behavior of the elevation prompt for standard users
- If it is set to
Automatically deny elevation requests
, you will not be able to use Administrator permissions while running under a standard user account.
- If this is set to any of the
Prompt for credentials...
settings, and the above process for running appwiz.cpl
elevated still does not work for you, then you may have a different problem.
Those instructions were wrong and have been fixed. Here's the usage for runas
:
RUNAS USAGE:
RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]
/user:<UserName> program
RUNAS [ [/noprofile | /profile] [/env] [/savecred] ]
/smartcard [/user:<UserName>] program
RUNAS /trustlevel:<TrustLevel> program
Notice that in all three variations, you can specify only a program to be run, nothing else. They mean it: You cannot specify any arguments to the program as separate words. Any arguments must be embedded into the "program" string with surrounding quotes.
Also not made clear is that runas
will not pass the current directories; it always starts in C:\Windows\System32
. So any program you specify must either be in a PATH
directory or given as a full path. You cannot use a relative path. And of course, any ACLs on that executable or the directories on its path must allow access by the user you'd like to run it as.
The good news is that runas
will accept a .cmd
file as a "program".
As a practical matter, what this means is that to do what you want, you'll probably want to create a .cmd
file in a directory both users can access, then pass the full path. For example:
runas /u:Fred "C:\Users\Public\foo.cmd"
The final wrinkle is that runas
can start a program as another user, but it can't elevate. There's no way to cause it to generate the UAC prompt. If you'd like to run something "as administrator" using runas
, you'll have to enable the builtin Administrator account, which always runs elevated anyway, and specify that user name.
If that's not going to work for you and you need a generalized ability to pass arguments and/or current directories or if you need to run something elevated as something other than Administrator, you'll need a genuine su
, like this one.
Best Answer
runas
does not elevate a program. Starting with Vista, processes are no longer giving admin privileges just because the user has admin credentials. This is because of UAC.When Vista and Server 2008 came out, this was especially a pain point for system admins because you could not launch programs with admin privileges from a script.
To elevate(the proper term for this process) a program from the commandline, you can do a few ways.
If you just need to elevate one command, you can type it into the start menu and hit CTRL Shift Enter.
If you need to elevate commands from a batchfile, you'll need to covert the script to a VBScript or JScript file. Or just download the excellent Elevate powertoys.
Edit:
For more clarification: http://technet.microsoft.com/en-us/magazine/2008.06.elevation.aspx
UAC documentations:
http://technet.microsoft.com/en-US/library/cc753413.aspx