Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed VBScript inside Windows batch file

Is it possible to embed VBScript within a batch file?

I currently have a .CMD file that calls a .VBS file using

cscript //NoLogo MyScript.vbs

but I'd prefer to distribute just a single .CMD file.


EDIT: There is a similar question with answers on how to do this without generating an intermediate file at all: Is it possible to embed and execute VBScript within a batch file without using a temporary file?

like image 230
sourcenouveau Avatar asked Oct 27 '10 21:10

sourcenouveau


People also ask

Can you run VBScript in CMD?

VBScript - Running Scripts from the Command Prompt. Windows Script Host enables you to run scripts from the command prompt. CScript.exe provides command-line switches for setting script properties.


1 Answers

http://www.computerhope.com/forum/index.php?topic=103686.0

@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
like image 120
drudge Avatar answered Sep 26 '22 17:09

drudge