Hi,

From a VBScript, I am trying to launch an exe that's in C:\Program Files\Form\Test.exe.

If I use the following code, I get "The system cannot find the file specified." Code - 80070002.

Set oShell = CreateObject("WScript.Shell")
oShell.Run "c:\Program Files\UserForm\Test.exe"

If I put the file in c:\windows, and change the following line, it works.

oShell.Run "c:\Program Files\UserForm\Test.exe"

to

oShell.Run "c:\Windows\Test.exe"

How do i set the path, and then get it to run the file in the correct location?

Thanks!
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Try

oShell.Run "c:\Progra~1\UserForm\Test.exe"
Answered 12/11/2007 by: turbokitty
Sixth Degree Black Belt

Please log in to comment
0
or try
oShell.Run """c:\Program Files\UserForm\Test.exe"""
Answered 12/11/2007 by: AngelD
Red Belt

Please log in to comment
0
Thanks for your replies - using Program~1 instead of Program Files worked.

Cheers.
Answered 12/11/2007 by: Meic
Second Degree Blue Belt

Please log in to comment
0
Thanks for your replies - using Program~1 instead of Program Files worked.Ever heard of defensive programming? Your code now assumes that a) the 'Program Files' folder is on the C: drive and b) that its short name will always be 'PROGRA~1'. In 99.99% of cases, both of these assumptions will be true but not always.

Interrogate the registry (or less optimally, the environment variable 'ProgramFiles') to divine the actual location of the 'Program Files' folder. Then either wrap the command line in quotes or, if you want the short name, use FileSystemObject's ShortPath property.
Answered 12/12/2007 by: VBScab
Red Belt

Please log in to comment
0
Thanks for your comments - will look into this...
Answered 12/12/2007 by: Meic
Second Degree Blue Belt

Please log in to comment
Answer this question or Comment on this question for clarity