- Run Cmd As Administrator Windows 7 Batch File
- Always Run Cmd As Administrator Windows 7
- Windows Command Line Run As Administrator
Active3 years, 8 months ago
Run a Command as Administrator from the Run Box in Windows 7, 8, or 10. Hit Windows+R to open the Run box. Type the name of whatever command—or program, folder, document, or website—you want to open. After typing your command, hit Ctrl+Shift+Enter to run it with admin privileges. Hitting Enter runs the command as a normal user. And by the way.
This question already has an answer here:
- Is there any 'sudo' command for Windows? 14 answers
On Linux, we can use
to run a shell as the superuser.
On Windows 7, we can use
Start menu -> (in search box, type) cmd -> Right click on search result and choose Run as Administrator
to run a command prompt as an administrator. Is there also a command prompt line that is like Linux's
Peter Mortensensudo
or su
so as to start a shell as an administrator?8,5881616 gold badges6262 silver badges8585 bronze badges
nopolenopole4,4122222 gold badges9898 silver badges159159 bronze badges
marked as duplicate by Ƭᴇcʜιᴇ007, Tog, Kevin Panko, David, RamhoundFeb 22 '14 at 8:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
10 Answers
The
runas
command is the closest thing to what you're looking for:The format is
runas
, the username you want to run as, other options, and then the program you want to run. Run Cmd As Administrator Windows 7 Batch File
If you're on a domain, you can use:
This can be run from the
Run
box ( Win+R ) or from a command window.Note, however, that this is not exactly like
surfasbsudo
- you can't use it to elevate yourself, just run something as a different user. If you're already have administrative rights, a runas to your account will give you the same access as the regular command (unless, of course, you runas a different administrator account, which will grant those administrator's rights to the new shell).21.1k33 gold badges4545 silver badges7272 bronze badges
Jared HarleyJared Harley11.5k33 gold badges3434 silver badges5050 bronze badges
Try creating a shortcut to cmd.exe. Right Click > Properties.Click on Advanced button. And tick the box 'Run as Administrator' and click OK.
Assign it a shortcut key if you want.
And you could also assign the default location for the CMD prompt to start in.. eg %CD%
Lance Roberts7,11488 gold badges4444 silver badges7676 bronze badges
MethicalMethical
Another alternative is to click Start and type cmd, followed by Ctrl + Shift + Enter
Source: Microsoft Technet
hanxuehanxue1,94444 gold badges2222 silver badges4545 bronze badges
Use SuRun.
Always Run Cmd As Administrator Windows 7
It works on Windows 8 as well. It runs the application in 'admin' mode without a prompt, yet you have greater control on what applications are run (you can see it on the SuRun's control panel applet). It works great in a batch file too...
Peter Mortensen8,5881616 gold badges6262 silver badges8585 bronze badges
KippaxKippax
Create a batch file such as sudo.bat, and type the following commands and then save in the PATH:
To use it, for an instance,
sudo cmd net start fms
, however, the script won't work if there's quotemark in command line.CosmoreCosmore
If you want a command-line solution: download hstart from http://www.ntwind.com/software/hstart.html and extract hstart.exe or hstart64.exe to somewhere on your path. You can start an elevated command prompt with
hstart /runas cmd
or hstart64 /runas cmd
.But the fastest way (as noted in a comment for the question) is still to press Windows, type
Peter Mortensencmd
and press Ctrl + Shift + Enter.8,5881616 gold badges6262 silver badges8585 bronze badges
LukeLuke97511 gold badge77 silver badges1515 bronze badges
I was frustrated with the existing solutions for this, so I wrote a little Node.js script which should be more familiar to *nix users.
It elevates the current user with no password prompts (just UAC), redirects stdin and stdout, and runs in the same console window.
Peter Mortensen8,5881616 gold badges6262 silver badges8585 bronze badges
teh_senausteh_senaus
The Open Command Prompt Shell Extension can add this capability for you as well.
afrazierafrazier21.1k22 gold badges4949 silver badges8282 bronze badges
I include genuine
Nicole HamiltonNicole Hamiltonsu
and sudo
commands with my Hamilton C shell to run a command as another user or elevated (with the UAC prompt) or both, i.e., elevated as another user. Unlike runas
and other alternatives, my su
and sudo
know how to pass current directories, environment variables and long command lines. This is a commercial product but there is a free version. Full disclosure: I'm the author. But I'm also happy to answer questions.8,84911 gold badge1313 silver badges3636 bronze badges
Peter MortensenWindows Command Line Run As Administrator
8,5881616 gold badges6262 silver badges8585 bronze badges
Tomáš KafkaTomáš Kafka