Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

run executable and pass options in vbscript

Posted on 2007-12-04
6
4,436 Views
Last Modified: 2010-04-21
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("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")

If FSO.FileExists(AppToRun) Then
WSH.Run AppToRun
Else
MsgBox ApptoRun & " Does not Exist"  
End If
0
Comment
Question by:ramagoni_kiran
  • 3
  • 3
6 Comments
 
LVL 18

Expert Comment

by:BSonPosh
ID: 20407833
I would use powershell, but if you like vbscript you can use wscript.arguments something like this... sorry its been a long time :)

Option Explicit

Dim FSO
Dim WSH

Const AppToRun = "d:\myscripts\pinch.exe" + wscript.arguments(0) + " " + wscript.arguments(1)

Set WSH = WScript.CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")

If FSO.FileExists(AppToRun) Then
WSH.Run AppToRun
Else
MsgBox ApptoRun & " Does not Exist"  
End If
0
 
LVL 1

Author Comment

by:ramagoni_kiran
ID: 20407915
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.
0
 
LVL 18

Expert Comment

by:BSonPosh
ID: 20408237
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("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")

If FSO.FileExists(AppToRun) Then
WSH.Run AppToRun
Else
MsgBox ApptoRun & " Does not Exist"  
End If
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 1

Author Comment

by:ramagoni_kiran
ID: 20412495
That did not work. Gives an error at line 11 char 71.

Error: Expected Literal constant

Any ideas ?
0
 
LVL 18

Accepted Solution

by:
BSonPosh earned 500 total points
ID: 20412739
Try this
#############
Option Explicit

Dim FSO
Dim WSH
Dim strServer
Dim strPort
Dim AppToRun

strServer = inputbox("Server Name")
strPort = inputbox("Port")

AppToRun = "d:\myscripts\pinch.exe " + strServer + " " + strPort

Set WSH = WScript.CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")

If FSO.FileExists(AppToRun) Then
WSH.Run AppToRun
Else
MsgBox ApptoRun & " Does not Exist"  
End If
0
 
LVL 1

Author Closing Comment

by:ramagoni_kiran
ID: 31412723
Thanks BSonPosh. That worked.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
How to install and configure Citrix XenApp 6.5 - Part 1. In this video tutorial we have explained step by step installation of Citrix XenApp 6.5 Server on Windows Server 2008 R2 is explained in this video. We have explained the difference between…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question