Create a su command for Windows Command Prompt

Posted on 16.05.17   CLI sudo SysAdmin Windows

As an IT tech I often have to open my command prompt as my domain administrator user which has administrator access on remote computers. I always forgets to right-click cmd and choose “Run as …” so I figured out a little shortcut for those times to mimic the su function in Linux.

Please note this won’t turn your currently open command prompt into an elevated one, it will just run a new cmd.exe process as the user you need.

Open an elevated command prompt and change directory to %windir%\system32 and run this command:

echo runas /user:domain\username "cmd" > sudo.bat

Now you can type “sudo” wherever (in your Run window or an existing cmd prompt) and it will prompt you for the password and open a new cmd window with the pre-defined user.

More on ITDB

Managing WiFi profiles in Windows 10


How to debug a non starting application with ProcMon


Turn off CTRL + ALT + DEL at login prompt Windows 10


Create a cmd alias/shortcut for issuing commands on remote computer


Fix twitchy/wobbling touchpad for Ubuntu based distributions