"Bukkake Face" <admin@xxxxxx> wrote in message
On Jul 8, 9:54 am, "Gavaskar" <nos...@xxxxxx> wrote:
> I'm having troubles trying to run a program with wshShell.run
> The program takes two arguments ..... \myprogram.exe setconfig c:\filename
> Here is what I'm doing, I have the user run a script from the folder that
> myprogram is in.
> C:\Program Files\My Company Name\Driver\version001\SetConfigpath.vbs
> ScriptName = wscript.Scriptfullname 'gets me C:\Program Files\My Company
> scriptpath = replace(ScriptName,"SetConfigpath.vbs","") ' removes
> Now I need to run C:\Program Files\My Company
> Name\Driver\version001\myprogram.exe setconfig C:\filename
> I think I need to do this, but the whitespaces and number of """ are
> me grief.
> wshShell.Run scriptpath & " setconfig " & "C:\filename", 3,true
> I have to use the variable scriptpath, I can't hard code it, because it
> Any Ideas????
wshShell.Run chr(34) & scriptpath & chr(34) & " setconfig " & "C:
chr(34) is the character code for " which will encapsulate your
scriptpath with " and enable you to use white spaces.
Alternatively, replace any quotes embedded in your string with two quotes.
strCmd = """" & scriptpath & """ setconfig " & """C:\filename"""
wshShell.Run strCmd, 3, True
I added the Wscript.Echo command for troubleshooting only. If it displays
the correct command, with spaces and quotes in the correct places, you are
good to go. Not I also placed the last parameter in quotes in case it has
Actually, the usual practice is to use %comspec% to invoke the proper
command processor for your OS. For example:
strCmd = "%comspec% /c """ & scriptpath & """ setconfig " &
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net