Skip to content

Instantly share code, notes, and snippets.

@hymkor
Created April 11, 2015 19:36
Show Gist options
  • Save hymkor/6148dc1aecdc78d83add to your computer and use it in GitHub Desktop.
Save hymkor/6148dc1aecdc78d83add to your computer and use it in GitHub Desktop.
コマンドラインから管理者権限でコマンドを実行するバッチファイル(JScript)
@if (0) == (0) echo off
cscript //nologo //E:JScript "%~f0" %*
exit /b 0
@end
var program = "CMD.EXE";
var argv="";
var args = WScript.Arguments;
if( args.length >= 1 ){
program = args.Item(0);
if(args.length >= 2 ){
argv = args.Item(1);
for(var i=2 ; i < argv.length ; i++ ){
argv = argv + " " + args.Item(i);
}
}
}
var shellApp = new ActiveXObject("Shell.Application");
shellApp.ShellExecute(program,argv,"","runas");
// vim:ft=javascript:
@hymkor
Copy link
Author

hymkor commented Jul 22, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment