The (default) PATHEXT environment variable contains .vbs/.js/.wsf but wscript.exe is usually set as the default windows scripting engine host, so running scripts in a terminal is a big pain. What if we could put the WSH script inside a batch file so we don’t have to prefix every call with cscript //nologo ?
@if (1==1) @if(1==0) @ELSE
@echo off&SETLOCAL ENABLEEXTENSIONS
cscript //E:JScript //nologo "%~f0" %*
@goto :EOF
@end @ELSE
WScript.Echo("hello from WSH");
@end
If there ever was a huge scripting hack, this is it. Somehow it is both “valid” BAT and JScript syntax! The @if syntax requires MS:JScript v3 (IE4+), on the batch side of things, %~f0 and %* requires at least NT4, maybe NT5.
March 3, 2010 at 13:12 |
Why don’t you blog any more? I LOVED your blog entries (and the topic) š
March 25, 2013 at 12:46 |
This is ugly genius. I love it!