Windows Vista Forums

wshshell.run a program from Program Files

  1. #1


    Gavaskar Guest

    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

  2. #2


    Bukkake Face Guest

    Re: wshshell.run a program from Program Files

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

    > 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

  3. #3


    Richard Mueller [MVP] Guest

    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:

    > 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

wshshell.run a program from Program Files

Similar Threads
Thread Forum
What is the difference between c:\Program Files and C:\Program Files(x86)?
If the later is for 64-bit programs, I don't see why it matters which go in which folders. In fact, I find it rather confusing because I have...
Vista General
Deleting program files and keeping program files x86?
Hi, I have Windows Vista Ultimate x64, and it came with 2 set of program files: program files, and program files x86. Since my hard drive is only 100...
General Discussion
After a program is closed, Vista informs that the program has stoppedworking. Huh?
After I close Paradox for Windows, Vista pops up a dialog every time informing me that the program has "stopped working". "A problem caused the...
Vista General
Uninstalled Program, but Program Name Remains in Program & Featur
I attempted to install a web camera on my Vista computer. I only got a partial installation so I uninstalled it from Control Panel>Program and...
Vista General
Moving Program Files and Program Data
I am going to repartition my C: drive and want to move my program files to a new location. I know all about the path-related headache that this...
Vista General
program Install and program has stopped working
Hello, when I install new programs , I get adware 2007 has stopped working How can I fix this? Its seems its starting to happen to more and...
Vista General
Spyware .exe program won't save or run into Program Files folder
Good Morning, I have downloaded a spyware program (Ad-Aware SE) from the internet and tried to save it to a new folder I called 'Security' in the...
Vista General