Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How does this work?

May
12,846
164
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?
 
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.
 
I get the "set" part. Are you sure about the colon and that VBS understands REM?
 
I get the "set" part. Are you sure about the colon and that VBS understands REM?
Code:
echo %@script[vbscript,a=10:a=a+1:set fso=CreateObject("Scripting.FileSystemObject"):set stdout=fso.GetStandardStream(1):stdout.WriteLine a:Rem This is a comment]

Joe
 
Code:
echo %@script[vbscript,a=10:a=a+1:set fso=CreateObject("Scripting.FileSystemObject"):set stdout=fso.GetStandardStream(1):stdout.WriteLine a:Rem This is a comment]

Joe
Got it. Thanks to both of you.
 
Back
Top