4

If you open a command prompt with a runas command, you will see a window that shows

(Running as some_user)

In the title bar, but if you right click on cmd.exe and choose Run as Administrator you will get a window that has:

Administrator cmd.exe

In the title bar. Oddly enough, these windows exhibit different behavior.

My question is how can I get the Administrator cmd.exe command prompt via command line? Or if it is even possible?

Massimo
  • 68,714
  • 56
  • 196
  • 319
naspinski
  • 177
  • 1
  • 4
  • 10

3 Answers3

3

Sorry for reviving an old question, but in my search for exactly the same thing Google led me here, so maybe this will help someone else looking for this. A community-written utility that does exactly what the OP looks for (equivalent of "/elevated" switch for "start" or "runas" command) actually exists:

Original version by John Robbins (C#):
http://www.wintellect.com/cs/blogs/jrobbins/archive/2007/03/27/elevate-a-process-at-the-command-line-in-vista.aspx

Rewrite by Johannes Passing (C - no dependency on .Net):
http://jpassing.com/2007/12/08/launch-elevated-processes-from-the-command-line/

Example usage:

c:\>elevate cmd.exe

Click OK in UAC prompt and you have an administrator command prompt.

nino
  • 31
  • 1
2

You didn't specify which O.S. you are using, but it should be Vista or later, as this is typical User Account Control behaviour.

Basically, in recent Windows system, even if your user account is a member of the Administrators group of the computer, you are still not allowed to perform administrative tasks; if you try to do something actually requiring administrative rights, either the action will fail or a popup window will appear asking you to confirm the action; if you instead only have standard user rights, you will be asked to provide the credentials of a real Administrator account.

If you right-click on something and choose to "Run as Administrator", UAC will ask you for confirmation and then you will be able to effectively bypass it, and the program (not just cmd.exe, BTW) will run with full administrative rights. This is especially useful with programs that are not compatible with UAC, and tend to silently fail if they require administrative rights and you just double-click on them while UAC is operational.

This of course doesn't have any relevance if UAC is disabled (that can be done via Control Panel), in which case double-clicking the icon or choosing to "Run as Administrator" do exactly the same thing; but the window title will still reflect the "elevated" status of that command prompt.

If you are asking "how can I run a command as Administrator (i.e. elevated) from the command line", AFAIK there is no built-in support for this. It would indeed be nice to have start /elevated or runas /elevated switches.

Massimo
  • 68,714
  • 56
  • 196
  • 319
  • I figured this was the answer, but I was hoping for another :P I would love that /elevated switch if it were possible. Thank you for the very well worded explanation. – naspinski Jul 20 '11 at 20:26
-1

to run any program elevated in Windows 7 , hold << LEFT CTRL>> and << LEFT SHIFT>> while launching the program. (ie type cmd and then << Left ctrl>>+<< left shift>>+<< enter>>

erik
  • 1
  • Read the question. Providing GUI instructions on how to do something, when the question specifically asks how to do it through the CLI is not really an answer. You're also a year late to this party. – HopelessN00b Sep 24 '12 at 20:17