How does this work?

May 20, 2008
12,169
133
Syracuse, NY, USA
I found an old BTM with this first line:
Code:
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?
 

samintz

Scott Mintz
May 20, 2008
1,555
26
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.