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 - wshell.run path building help

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


 
 

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 SpecsSystem Spec
Old 07-01-2009   #2 (permalink)
James Whitlow


 
 

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
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 SpecsSystem Spec
Old 07-01-2009   #3 (permalink)
ekkehard.horner


 
 

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
(1) The trailing '3, False' surely is a copy & paste artefact

(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 SpecsSystem Spec
Old 07-01-2009   #4 (permalink)
Gavaskar


 
 

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 SpecsSystem Spec
Reply

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


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