>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.