Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using WShell.run to execute an MSI but path has spaces 1

Status
Not open for further replies.

DFinnegan

MIS
May 22, 2002
8
US
I am trying to use VBScript to execute and MSI (based on some conditions). The problem I am having is that the path to the MSI has spaces in it, so I tried using Chr(32) but I still get an error stating that I am using incorrect command line parameters. How can I pass the full string to the msiexec.exe and have it run correctly using VBScript?

Code Example:
MSIEXE = "C:\Winnt\system32\msiexec.exe /I "
UpdPath = "X:\MYXP" & Chr(32) & "Update" & Chr(32) & "2 _ \WinXP\Update2\MSISetup\SMSInst.exe"

Set oExec = WshShell.Run(MSIEXE & UpdPath)
 
Oops! Forget the msiexec.exe part. I was trying to start the EXE file which points to an MSI. I am still getting an error when I try to execute the EXE file though:

Set oExec = WshShell.Run(UpdPath)
 
Hello DFinnegan,

First of all, .run returns an integer, so if you want to monitor the return code, just change the line to, say:
Code:
iRun = WshShell.Run(UpdPath)
regards - tsuji
 
Try this:
Code:
UpdPath=Chr(34) & "X:\MYXP Update 2\WinXP\Update2" _
& "\MSISetup\SMSInst.exe" & Chr(34)


Hope This Help
PH.
 
Thanks Tsuji and especially PHV! Both responses were a great help. I have been trying for a while to execute files that had spaces in the path and the Chr(34) pre & post-pends worked! Thanks again PHV! Definitely worth a star. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top