Open files via an elevated context menu program
- Open Olly executable's properties.
- Click the Compatibility tab.
- Check Run this program as an administrator.
ShellExecuteEx
is an API function, not a command. You could use it if you were developing an application to run other EXEs with elevated privileges.
If you want to run any program with elevated privileges from a command line, create a sudo.cmd
file in any directory in your PATH:
@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
Then type for example sudo notepad C:\example.txt
to open C:\example.txt
in elevated Notepad. (original source)