Created
January 8, 2013 09:05
-
-
Save sstur/4482361 to your computer and use it in GitHub Desktop.
Ensure a JS script runs in CScript on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global WScript */ | |
(function(ws) { | |
if (ws.fullName.slice(-12).toLowerCase() !== '\\cscript.exe') { | |
var cmd = 'cscript.exe //nologo "' + ws.scriptFullName + '"'; | |
var args = ws.arguments; | |
for (var i = 0, len = args.length; i < len; i++) { | |
var arg = args(i); | |
cmd += ' ' + (~arg.indexOf(' ') ? '"' + arg + '"' : arg); | |
} | |
new ActiveXObject('WScript.Shell').run(cmd); | |
ws.quit(); | |
} | |
})(WScript); | |
WScript.echo('We are now in CScript. Press Enter to Quit...'); | |
WScript.stdIn.readLine(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment