How does this work?

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
I found an old BTM with this first line:
set z=nothing:rem& cscript "%~f0" //E:VBS //NOLOGO &GOTO:EOF
The rest is VB script.
It works. How? In particular, what happens when cscript.exe reads the first line?


Scott Mintz
May 20, 2008
Solon, OH, USA
When you are setting a value to a variable that is actually an object then you must follow some special syntax. The SET keyword lets VBScript know that you are setting your variable equal to an object. In addition to this, you also have to set the variable equal to nothing after you are finished with it.

And I'm guessing that the colon is a statement separator. So VBScript sees a SET z=nothing followed by a REMark.

TC sees 3 statements - set, cscript, and goto.