I have a shell script that I converted to vbs. After some trial and error I got the script to work but I am hoping there is niftier way to accomplish passing parameters to an exe
The shell script looks like this…sets 12 parameters and then runs the
set PERCminiexe="C:\Perc\mini.exe"
set PERCminiopt="-f"
set PERCconfigfile="C:\Perc\config.txt"
set Monitor="MIS_Monitor"
set Entity="HR_Admin"
set Host="myserver.com"
set Service="HR"
set Alias="DEV52"
set xDate=""
set xTime=""
set State="ALERT"
set Text="This is a test firing from WMI from cmd"
%PERCminiexe% %PERCminiopt% %PERCconfigfile% %Monitor% %Entity% %Host% %Service% %Alias% %xDate% %xTime% %State% %Text%
When trying to run this in vbs I had to include a bunch of spaces and quotes to make the command run. Result looks something like this. I am looking for smarter way
PERCminiexe="C:\Perc\mini.exe" PERCminiopt="-f" PERCconfigfile="C:\Perc\config.txt" Monitor="MIS_Monitor" Entity="HR_Admin" Host=" myserver " Service="HR" Alias="DEV52" xDate=FormatDateTime(Date() ,2) xTime=FormatDateTime(now() ,4) State="ALERT" Text="This is a test firing event from WMI using vbs" Set WshShell = CreateObject("WScript.Shell") WshShell.run Chr(34) & PERCminiexe & Chr(34) & " " & Chr(34) & PERCminiopt & Chr(34) & " " & Chr(34) & PERCconfigfile & Chr(34) & " " & Chr(34) & Monitor & Chr(34) & " " & Chr(34) & Entity & Chr(34)& " " & Chr(34) & Host & Chr(34) & " " & Chr(34) & Service & Chr(34) & " " & Chr(34) & Alias & Chr(34) & " " & Chr(34) & xDate & Chr(34) & " " & Chr(34) & xTime & Chr(34) & " " & Chr(34) & State & Chr(34) & " " & Chr(34) & Text & Chr(34), 0, True Set WshShell = Nothing
Example program with parameters running directly from cmd window
mini.exe -f config.txt MIS_Monitor HR_Admin myserver HR DEV52 3/5/2002 10:22:12 ALERT "This is a test firing event from cmd line“