How to execute a batch file with a parameter from VBS


The below script is an example to show how to pass a parameter to a batch file from VBS.

StrComputer=”MYCOMPUTER”
Set oWsh = WScript.CreateObject(“WScript.Shell”)
sfcmd = chr(34) & oWsh.CurrentDirectory &”\install.bat”&chr(34)&” ” &StrComputer
oWsh.Run sfcmd,0,True       ‘ Hidden,  wait

Note: In the batchfile set the StrComputer=%1 to get the StrComputer value mentioned in VBS file.

Advertisements

0 Responses to “How to execute a batch file with a parameter from VBS”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: