By David Wiseman (Administrator)Created 07 Nov 2006
My Rating:
Not Rated

Run Program from VBScript

Language:  VBScript


Windows XP Yes Windows 2003 Yes
Windows 2000 Yes Windows NT Unknown
Vista Unknown Windows 2008 Unknown

Run an external program from VBScript.


Line Numbers: On  Off      Plain Text
strProgramPath = "C:\Windows\system32\calc.exe"

set objShell = createobject("Wscript.Shell")

objShell.Run strProgramPath


Got a useful script? Click here to upload!


  Post Comment
Order By:  
User Comments
Posted On: 11/7/2011 11:31:43 AM

I know this is an old posting, but I've run into an issue using this and google hasn't been of much use in fixing it so far. I've got a pretty simple script that puts together a command line to launch a batch file and redirect its output. This works fine using createObject() as shown above, but when all is said and done, there are 2 cmd.exe processes left laying around the OS (running this on Windows 2003 SP2). Below is a the pertinent portion of the code that I'm running.. [code]Option Explicit Dim ScriptDir, ServerName, ServerPort Dim strDay, strMonth, strYear, strHr, strMin, strDTG Dim strShell, strExe ScriptDir = "D:\prod\apps\cy\" If WScript.Arguments.Count = 2 Then ServerName = WScript.Arguments.Item(0) ServerPort = WScript.Arguments.Item(1) Else Wscript.Echo "Usage: cy_startup.vbs ServerName ServerPort" Wscript.Quit End If strDay = Day(Date) strMonth = Month(Date) strYear = Year(Date) strHr = Hour(Time) StrMin = Minute(Time) strDTG = strYear & strMonth & strDay & "_" & strHr & strMin strExe = ScriptDir & "start_" & ServerName &".bat > D:\logs\prod\" & ServerName & "\" & ServerName & ".stdout." & strDTG & ".log 2> D:\logs\prod\" & ServerName & "\" & ServerName & ".stderr." & strDTG & ".log" set strShell = createObject("Wscript.Shell") strShell.Run strExe WScript.echo "Created: " & strExe & " on " & strComputer set strShell = Nothing WScript.Quit [/code]