Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - wshshell.run a program from Program Files

Reply
 
Old 07-07-2009   #1 (permalink)
Gavaskar


 
 

wshshell.run a program from Program Files

Ok

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
Name\Driver\version001\SetConfigpath.vbs

scriptpath = replace(ScriptName,"SetConfigpath.vbs","") ' removes
SetConfipath.vbs

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 giving
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 may
change.

Any Ideas????

Thanks
G






My System SpecsSystem Spec
Old 07-07-2009   #2 (permalink)
Bukkake Face


 
 

Re: wshshell.run a program from Program Files

On Jul 8, 9:54*am, "Gavaskar" <nos...@xxxxxx> wrote:
Quote:

> Ok
>
> 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
> Name\Driver\version001\SetConfigpath.vbs
>
> scriptpath = replace(ScriptName,"SetConfigpath.vbs","") ' removes
> SetConfipath.vbs
>
> 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 giving
> 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 may
> change.
>
> Any Ideas????
>
> Thanks
> G
Use :

wshShell.Run chr(34) & scriptpath & chr(34) & " setconfig " & "C:
\filename", 3,true

chr(34) is the character code for " which will encapsulate your
scriptpath with " and enable you to use white spaces.
My System SpecsSystem Spec
Old 07-07-2009   #3 (permalink)
Richard Mueller [MVP]


 
 

Re: wshshell.run a program from Program Files


"Bukkake Face" <admin@xxxxxx> wrote in message
news:34e1a82c-9d92-44a8-8af3-06635f0d0a73@xxxxxx
On Jul 8, 9:54 am, "Gavaskar" <nos...@xxxxxx> wrote:
Quote:

> Ok
>
> 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
> Name\Driver\version001\SetConfigpath.vbs
>
> scriptpath = replace(ScriptName,"SetConfigpath.vbs","") ' removes
> SetConfipath.vbs
>
> 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
> giving
> 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
> may
> change.
>
> Any Ideas????
>
> Thanks
> G
Use :

wshShell.Run chr(34) & scriptpath & chr(34) & " setconfig " & "C:
\filename", 3,true

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.
For example:

strCmd = """" & scriptpath & """ setconfig " & """C:\filename"""
Wscript.Echo strCmd
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
any spaces.

Actually, the usual practice is to use %comspec% to invoke the proper
command processor for your OS. For example:

strCmd = "%comspec% /c """ & scriptpath & """ setconfig " &
"""C:\filename"""

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
What is the difference between c:\Program Files and C:\Program Files(x86)? Vista General
Solved Deleting program files and keeping program files x86? General Discussion
Uninstalled Program, but Program Name Remains in Program & Featur Vista General
Moving Program Files and Program Data Vista General
Spyware .exe program won't save or run into Program Files folder Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46