WSH Run does recognizes only short DOS convention file path names 
Author Message
 WSH Run does recognizes only short DOS convention file path names

When the WSH Run method is used with a file path specification that includes
spaces,
such as "c:\program files\myexe.exe" the Run method fails. If the path is
changed to:
"c:\progra~1\myexe.exe" the method is successful.

The WHS error message says ".. cannot find file.."

How do you call Run with long file path names?



Thu, 04 Sep 2003 05:15:20 GMT  
 WSH Run does recognizes only short DOS convention file path names

Quote:

> When the WSH Run method is used with a file path specification that includes
> spaces,
> such as "c:\program files\myexe.exe" the Run method fails. If the path is
> changed to:
> "c:\progra~1\myexe.exe" the method is successful.

> The WHS error message says ".. cannot find file.."

> How do you call Run with long file path names?

You must enclose the path in double quotes.

To achieve the effect of: "c:\program files\myexe.exe"

You have to pass it as:

Dim sPath
sPath = """c:\program files\myexe.exe"""

OR
sPath = chr(34) & "c:\program files\myexe.exe" & chr(34)

goShell.Run sPath     ' Now run behaves as expected - it runs!

Branimir



Thu, 04 Sep 2003 06:10:45 GMT  
 WSH Run does recognizes only short DOS convention file path names
If the path contains any spaces, enclose the path in quotes.  In a literal string, an embedded quote
is represented as 2 quotes.  You can also use Chr(34) which returns a quote character.

shell.run """c:\program files\myexe.exe"""

or

shell.run chr(34) & "c:\program files\myexe.exe" & chr(34)

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> When the WSH Run method is used with a file path specification that includes
> spaces,
> such as "c:\program files\myexe.exe" the Run method fails. If the path is
> changed to:
> "c:\progra~1\myexe.exe" the method is successful.

> The WHS error message says ".. cannot find file.."

> How do you call Run with long file path names?



Thu, 04 Sep 2003 06:25:23 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Converting Long File Names to Short File Names

2. Getting short file name from long file name:

3. Converting Long File Names to Short File Names

4. Converting Short File Names to Long File Names

5. how to get short path name

6. Converting Paths having short name to long versions

7. registry %1 argument and short/long path names

8. Get Short File Name in VBScript

9. Long Path Names give Runtime error 76 - Path not found

10. Long Path Names give Runtime error 76 - Path not found

11. Convert Long Path to Short

12. naming conventions

 

 
Powered by phpBB® Forum Software