![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 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 Specs![]() |
| | #3 (permalink) |
| | 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 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 Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| What is the difference between c:\Program Files and C:\Program Files(x86)? | Vista General | |||
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 | |||