Andy B
Andy B

Reputation: 13

Creating a basic vbscript to call a single command

I have installed program where I need to run a command line in order for it to do something. So I want to create a simple vbscript to carry out this command ion order for me to deploy the cmd to several machines using SCCM2012.

The program sits in the %ProgramFiles% directory and it is an 'exe' file with a cmd switch I am wanting to use, example

program.exe -testcmd

Hope this makes sense and can anyone assist please?

I have looked at the forums but I don't understand what all the command mean in the script.....(I am hopeless)

Upvotes: 0

Views: 49

Answers (1)

Bond
Bond

Reputation: 16321

You can use the Run method of the WshShell object. Just make sure to put quotes around the path to your EXE. In VBScript, you need to escape embedded quotes (by doubling them) or you can use the Chr(34) statement.

strCmd = Chr(34) & "%ProgramFiles%\program.exe" & Chr(34) & " -testcmd"
CreateObject("WScript.Shell").Run strCmd

Upvotes: 1

Related Questions