Monday 16 April 2018

On Windows 7, is there a command prompt line that can start cmd as an administrator?



On Linux, we can use


sudo bash

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 sudo or su so as to start a shell as an administrator?



Answer



The runas command is the closest thing to what you're looking for:


runas /user:username cmd.exe

The format is runas, the username you want to run as, other options, and then the program you want to run.


If you're on a domain, you can use:


runas /user:DOMAIN\USERNAME cmd.exe

This can be run from the Run box ( Win+R ) or from a command window.


Note, however, that this is not exactly like sudo - 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).


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...