A leading colon in a [gs batch] [gs file] is ignored because it denotes a label; it is ignored in VBscript because it is a command separator. Thus the batch [gs script] can search itself for lines beginning with a colon and write them out to a temporary vbs file and then execute it.
Example
@echo off
echo This is batch
:wscript.echo "This VBScript"
:wscript.echo "Today is " & day(date) & "-" & month(date) & "-" & year(date)
findstr "^:" "%~sf0">temp.vbs & cscript //nologo temp.vbs & del temp.vbs
echo This is batch again
The result
This is batch
This VBScript
Today is 21-4-2010
This is batch again
Maybe you want to use some GUI feature of wscript e.g. to get user input...
Another Example
@echo off
:wscript.echo InputBox("Enter your name")
findstr "^:" "%~sf0">temp.vbs & for /f "delims=" %%N in ('cscript //nologo temp.vbs') do set name=%%N & del temp.vbs
echo You entered %name%
SOURCE | LINK | LANGUAGE | ENGLISH |
How to Embed VBScript in cmd/bat script (VBscript vs. Batch DOS) – http://heelpbook.altervista.org/?p=36033 – 01/03/2013 – 12:00 – HeelpBook – Visit http://www.heelpbook.net OR http://mobile.heelpbook.net on your tablet! #heelpbook