Sunday, 14 April 2019

VB Scripts: How do you run VB scripts from batch file | Pass parameters into vb script file from batch file

in your batch file, use this below command to execute vbscript

Execute vbs file from batch file

Ex:
'cscript vbfilename

cscript mytestvbscript.vbs



Passing parameters to a vb script

Ex2: 

'dbservername is my 1st parameter
'dbname is my second parameter


cscript mytestvbscript.vbs testmachine1 testdb 


in the vb script code, to fetch the passed values, use below code

strdbservername = WScript.Arguments.Item(0)
strdbname = WScript.Arguments.Item(1)


'to print the fetched variables

wscript.echo strdbservername 
wscript.echo strdbname 





No comments:

Post a Comment

VBScript: How to use Dictionary in VBScript | VBScript objects

=>To declare and create object of a vbscript dictionary: Dim objDictionary Set objDictionary = CreateObject("Scripting.Dictionar...