Skip to content

Instantly share code, notes, and snippets.

@hanji
Created September 8, 2012 07:55
Show Gist options
  • Select an option

  • Save hanji/3672652 to your computer and use it in GitHub Desktop.

Select an option

Save hanji/3672652 to your computer and use it in GitHub Desktop.
WSH script to launch application with elevated privileges
(function(){
if (WScript.Arguments.Length !== 0){
var app = WScript.Arguments(0);
} else {
WScript.Echo('sudo <application> [<parameters>]');
WScript.Quit(1);
}
var sh = new ActiveXObject('Shell.Application');
var args = [];
for (i = 1; i < WScript.Arguments.Length; ++i){ args.push('"' + WScript.Arguments(i) + '"') }
args = args.join(' ');
sh.ShellExecute(app, args, '', 'runas');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment