Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WSH Run command with space in file path
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00356898
Message ID:
00356997
Views:
10
>I'm getting an OLE error if I use Windows Script Host. This only occurs if the path to the exe to be run has a space in it. Does anybody know of any reason.
>
>The code is basically like this:-
>
>
lcFileName=GetProgToRun()

try adding:

IF " " $ lcFileName
   lcFileName = '"' + lcFileName + '"'
ENDIF

>loShell=CreateObject("wscript.shell")
>lnResult=loShell.Run(lcFileName, 1, .T.)
>
>This works perfectly well if there is no space in the file name. The exe file is definitely there as this is validated before running.
>

Yes; it's the command line parser acting as expeted - a space is a delimiter for the CLI, and if you want it not to be treated as such, the full path must be quote encapsulated.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform