MJN All Blog Cheatsheets Elasticsearch GCP JS LinuxBash Misc Notes Other ShortcutKeys / - Search

Home / Notes / Emulating sudo in dos cmd


I found a useful method for running a dos command as Administrator.

Create a script sudo.bat:

@echo Set objShell = CreateObject("Shell.Application") > %temp%\sudo.tmp.vbs
@echo args = Right("%*", (Len("%*") - Len("%1"))) >> %temp%\sudo.tmp.vbs
@echo objShell.ShellExecute "%1", args, "", "runas" >> %temp%\sudo.tmp.vbs
@cscript %temp%\sudo.tmp.vbs

To open a new cmd window running as administrator:

> sudo cmd

This page was generated by GitHub Pages. Page last modified: 24/05/17 16:27