Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ShellExecute does not recognize long path names?
Message
From
08/01/2001 05:41:40
 
 
To
08/01/2001 05:25:28
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00460480
Message ID:
00460483
Views:
11
>I am trying to launch an executable file with the ShellExecute win32api function with the following parameters:
>
>M.SHELL_RET = ShellExecute(FindWindow(0, _SCREEN.caption), ;
> "open", "c:\softwares\general\finservices - modelo 2\finservices.exe", ;
> "101", "c:\softwares\general\finservices - modelo 2", 1)
>
>The exe does not launch and I receive the following value in M.SHELL_RET: 2
>
>What is happening? I am sure about the exe path and exe file name.

Since there are embedded spaces in the names, you need to leave the strings quote-encapsulated; try:

M.SHELL_RET = ShellExecute(FindWindow(0, _SCREEN.caption), ;
"open", '"c:\softwares\general\finservices - modelo 2\finservices.exe"', ;
"101", '"c:\softwares\general\finservices - modelo 2"', 1)

Note that I added quote encapsulation so that I passed:

"c:\softwares\general\finservices - modelo 2\finservices.exe"

rather than:

c:\softwares\general\finservices - modelo 2\finservices.exe

as the lpFile parameter.

There's absolutely no advantage to using ShellExecute() here - a simple RUN like:
cOriginalDir = FULLPATH(CURDIR())
CD "c:\softwares\general\finservices - modelo 2"
RUN /N1 "c:\softwares\general\finservices - modelo 2\finservices.exe" 101
CD (cOriginalDir)
should work just fine. ShellExecute() does not allow you to wait on completion, and performing the Open verb on an executable launches the executable

If you need to wait on termination, you can create an instance of WScript.Shell and use it's Run method, or download API_APPRUN from here on the UT.
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
Next
Reply
Map
View

Click here to load this message in the networking platform