Unix like sudo command on Windows
Common question: ‘Is there any ‘sudo’ command for Windows?’
An answer is here.
csudo in ConEmu
ConEmu package contains (started from build 121028) batch file
%ConEmuBaseDir%
\csudo.cmd
.
When checkbox ‘Add %ConEmuBaseDir% to %PATH%’ is checked (‘ComSpec’ settings page),
you may just type csudo
in non-elevated prompt in your shell.
Note You may also define an alias sudo
for csudo.cmd
if you prefer simple sudo
notation.
Just go to the Environment settings page.
Note Don’t change file contents to avoid your changes loss when new update of ConEmu arrives, set up options as described below instead.
Note Elevated command will starts in new elevated ConEmu tab or pane.
Usage example
csudo dism /online /enable-feature /featurename:NetFX3 /All /Source:D:\sources\sxs /LimitAccess
Screenshots
Let type in command prompt ‘csudo diskpart’
Get UAC confirmation on Vista or later
Here we are, diskpart started elevated in a split
Script and options
As you can see, batch contains two parameters, which you may redefine: ConEmuSudoSplit
and ConEmuSudoConfirm
.
You may adjust them on the Environment settings page.
Variable | Value | Description |
---|---|---|
ConEmuSudoSplit |
VERT | Create new console in the split below current one |
HORZ | Create new console in the split rightward | |
NO | Create new console in the new tab | |
ConEmuSudoConfirm |
YES | When started command terminates ConEmu will show ‘Press Enter or Esc to close console…’ confirmation in started console |
NO | When started command terminates started console is closed automatically |
For example, if you want to start elevated command in new tab rather than in split just add the following line to your Environment:
set ConEmuSudoSplit=NO
Alias for cmd.exe
You may also setup an alias for cmd.exe
and Far Manager prompt.
Please read -new_console options for details.
alias sudo=ConEmuC.exe -c $* -new_console:ac