1

So I've created in context menu an "open with Ollydbg" option.How can I run olly as an administrator from that point on?What command or arguments should I use?I run into a "ShellExecuteEx" command but still no luck

1
  1. Open Olly executable's properties.
  2. Click the Compatibility tab.
  3. 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)

0

The solution in this another answer won't work if the command line contains double quotes and/or ends with \", e.g. copy c:\foo.txt "c:\Program Files\". A modified version like below fixes that.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.