ramagoni_kiran
asked on
run executable and pass options in vbscript
I am a Citrix Engineer and want to use VBScript to execute Pinch.exe to check status of ports on my servers. I want to publish a VBscript in Citrix for the Firewall Team. Below is the vbscript that I use to run pinch.exe. it runs fine but I need to pass values to pinch.exe as the syntax for pinch.exe is:
pinch.exe <servername> <port>
I want to include an input box for users to enter the servername and port number. These values have to be passed to pinch.exe at run time.
Any suggestions ?
-------------------------- ---------- ---------- ---------- ---------- ---------- -------
Option Explicit
Dim FSO
Dim WSH
Const AppToRun = "d:\myscripts\pinch.exe"
Set WSH = WScript.CreateObject("WScr ipt.Shell" )
Set FSO = CreateObject("Scripting.Fi leSystemOb ject")
If FSO.FileExists(AppToRun) Then
WSH.Run AppToRun
Else
MsgBox ApptoRun & " Does not Exist"
End If
pinch.exe <servername> <port>
I want to include an input box for users to enter the servername and port number. These values have to be passed to pinch.exe at run time.
Any suggestions ?
--------------------------
Option Explicit
Dim FSO
Dim WSH
Const AppToRun = "d:\myscripts\pinch.exe"
Set WSH = WScript.CreateObject("WScr
Set FSO = CreateObject("Scripting.Fi
If FSO.FileExists(AppToRun) Then
WSH.Run AppToRun
Else
MsgBox ApptoRun & " Does not Exist"
End If
ASKER
Is there a way to prompt the user to enter the values and then pass it during runtime.. in this case the server name and port number.
Finally the command that needs to be executed is:
Pinch.exe <servername> <port number>
I got to get going with improving in VBScript, till then I'd appreciate answers as this is extremely urgent for firewall folks so that Citrix guys need not be on standby when they do their changes on firewalls.
Finally the command that needs to be executed is:
Pinch.exe <servername> <port number>
I got to get going with improving in VBScript, till then I'd appreciate answers as this is extremely urgent for firewall folks so that Citrix guys need not be on standby when they do their changes on firewalls.
Option Explicit
Dim FSO
Dim WSH
Dim strServer
Dim strPort
strServer = inputbox("Server Name")
strPort = inputbox("Port")
Const AppToRun = "d:\myscripts\pinch.exe " + strServer + " " + strPort
Set WSH = WScript.CreateObject("WScr ipt.Shell" )
Set FSO = CreateObject("Scripting.Fi leSystemOb ject")
If FSO.FileExists(AppToRun) Then
WSH.Run AppToRun
Else
MsgBox ApptoRun & " Does not Exist"
End If
Dim FSO
Dim WSH
Dim strServer
Dim strPort
strServer = inputbox("Server Name")
strPort = inputbox("Port")
Const AppToRun = "d:\myscripts\pinch.exe " + strServer + " " + strPort
Set WSH = WScript.CreateObject("WScr
Set FSO = CreateObject("Scripting.Fi
If FSO.FileExists(AppToRun) Then
WSH.Run AppToRun
Else
MsgBox ApptoRun & " Does not Exist"
End If
ASKER
That did not work. Gives an error at line 11 char 71.
Error: Expected Literal constant
Any ideas ?
Error: Expected Literal constant
Any ideas ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks BSonPosh. That worked.
Option Explicit
Dim FSO
Dim WSH
Const AppToRun = "d:\myscripts\pinch.exe" + wscript.arguments(0) + " " + wscript.arguments(1)
Set WSH = WScript.CreateObject("WScr
Set FSO = CreateObject("Scripting.Fi
If FSO.FileExists(AppToRun) Then
WSH.Run AppToRun
Else
MsgBox ApptoRun & " Does not Exist"
End If