![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| Guest | wshell.run path building help Hello I'm trying to run a program, lets use mspaint as an example. I've got mspaint in the folder path c:\Program Files\Company Name\Version-001\mspaint.exe c:\Program Files\Company Name\Version-002\mspaint.exe c:\Program Files\Company Name\Version-003\mspaint.exe When I run the script, I query the file mspaint.exe for the version number, so I know which one to execute, and I assign that version ID to a variable VersionString. The returned string will be "Version-001" or "Version-002" or "Version-003" My problem is when I do a wshShell.run I'm having problems with the white spaces and adding the variable. Mypath = """c:\Program Files\Company Name\""" & VersionString & "\mspaint.exe", 3, False wshshell.run Mypath, 3, False I always get a error message that it can not find the specified file Any Ideas? |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: wshell.run path building help "Gavaskar" <nospam@xxxxxx> wrote in message news:%23JEIlgo%23JHA.4900@xxxxxx Quote: > Hello > > I'm trying to run a program, lets use mspaint as an example. > > I've got mspaint in the folder path > > c:\Program Files\Company Name\Version-001\mspaint.exe > c:\Program Files\Company Name\Version-002\mspaint.exe > c:\Program Files\Company Name\Version-003\mspaint.exe > > > When I run the script, I query the file mspaint.exe for the version > number, so I know which one to execute, and I assign that version ID to a > variable VersionString. > The returned string will be "Version-001" or "Version-002" or > "Version-003" > > > My problem is when I do a wshShell.run I'm having problems with the white > spaces and adding the variable. > > Mypath = """c:\Program Files\Company Name\""" & VersionString & > "\mspaint.exe", 3, False > > wshshell.run Mypath, 3, False > > I always get a error message that it can not find the specified file Mypath = """c:\Program Files\Company Name\" & VersionString & _ "\mspaint.exe""" You just needed to move the closing quotes for the command to the end of 'mspaint.exe' and remove the ',3, False' since that is part of your 'Run' command and not part of the variable assignment. |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: wshell.run path building help Gavaskar schrieb: Quote: > Hello > > I'm trying to run a program, lets use mspaint as an example. > > I've got mspaint in the folder path > > c:\Program Files\Company Name\Version-001\mspaint.exe > c:\Program Files\Company Name\Version-002\mspaint.exe > c:\Program Files\Company Name\Version-003\mspaint.exe > > > When I run the script, I query the file mspaint.exe for the version number, > so I know which one to execute, and I assign that version ID to a variable > VersionString. > The returned string will be "Version-001" or "Version-002" or "Version-003" > > > My problem is when I do a wshShell.run I'm having problems with the white > spaces and adding the variable. > > Mypath = """c:\Program Files\Company Name\""" & VersionString & > "\mspaint.exe", 3, False (2) If you WScript.Echo Mypath it will look like "c:\Program Files\Company Name\"Version-003\mspaint.exe (3) So Mypath = """c:\Program Files\Company Name\" & VersionString & "\mspaint.exe""" Quote: > > wshshell.run Mypath, 3, False > > I always get a error message that it can not find the specified file > > Any Ideas? |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: wshell.run path building help - THANKYOU - "James Whitlow" <jwhitlow.60372693@xxxxxx> wrote in message news:eZnAFto%23JHA.3768@xxxxxx Quote: > "Gavaskar" <nospam@xxxxxx> wrote in message > news:%23JEIlgo%23JHA.4900@xxxxxx Quote: >> Hello >> >> I'm trying to run a program, lets use mspaint as an example. >> >> I've got mspaint in the folder path >> >> c:\Program Files\Company Name\Version-001\mspaint.exe >> c:\Program Files\Company Name\Version-002\mspaint.exe >> c:\Program Files\Company Name\Version-003\mspaint.exe >> >> >> When I run the script, I query the file mspaint.exe for the version >> number, so I know which one to execute, and I assign that version ID to a >> variable VersionString. >> The returned string will be "Version-001" or "Version-002" or >> "Version-003" >> >> >> My problem is when I do a wshShell.run I'm having problems with the white >> spaces and adding the variable. >> >> Mypath = """c:\Program Files\Company Name\""" & VersionString & >> "\mspaint.exe", 3, False >> >> wshshell.run Mypath, 3, False >> >> I always get a error message that it can not find the specified file > Change your 'Mypath' live to look like this: > > Mypath = """c:\Program Files\Company Name\" & VersionString & _ > "\mspaint.exe""" > > You just needed to move the closing quotes for the command to the end of > 'mspaint.exe' and remove the ',3, False' since that is part of your 'Run' > command and not part of the variable assignment. > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Building a PC | Gaming | |||
| Building your own Rig | General Discussion | |||
| BUG? (Test-Path $path -IsValid) and empty $path | PowerShell | |||
| BUG/ANNOYANCE: PoSH autocompletes the full path rather than a minimal path | PowerShell | |||