Module: wine
Branch: master
Commit: 5704b4bec94688fac291bee1c75ccd76039107ed
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5704b4bec94688fac291bee1c…
Author: Jason Edmeades <us(a)edmeades.me.uk>
Date: Thu Apr 5 22:47:54 2007 +0100
cmd.exe: Attempt to launch pgm even if fails to locate it.
---
programs/cmd/wcmdmain.c | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 4a2d239..dc586f2 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -814,6 +814,7 @@ void WCMD_run_program (char *command, int called) {
BOOL extensionsupplied = FALSE;
BOOL launched = FALSE;
BOOL status;
+ BOOL assumeInternal = FALSE;
DWORD len;
@@ -849,6 +850,7 @@ void WCMD_run_program (char *command, int called) {
/* Loop through the search path, dir by dir */
pathposn = pathtosearch;
+ WINE_TRACE("Searching in '%s' for '%s'\n", pathtosearch, stemofsearch);
while (!launched && pathposn) {
char thisDir[MAX_PATH] = "";
@@ -917,8 +919,20 @@ void WCMD_run_program (char *command, int called) {
}
}
+ /* Internal programs won't be picked up by this search, so even
+ though not found, try one last createprocess and wait for it
+ to complete.
+ Note: Ideally we could tell between a console app (wait) and a
+ windows app, but the API's for it fail in this case */
+ if (!found && pathposn == NULL) {
+ WINE_TRACE("ASSUMING INTERNAL\n");
+ assumeInternal = TRUE;
+ } else {
+ WINE_TRACE("Found as %s\n", thisDir);
+ }
+
/* Once found, launch it */
- if (found) {
+ if (found || assumeInternal) {
STARTUPINFO st;
PROCESS_INFORMATION pe;
SHFILEINFO psfi;
@@ -938,7 +952,7 @@ void WCMD_run_program (char *command, int called) {
/* thisDir contains the file to be launched, but with what?
eg. a.exe will require a.exe to be launched, a.html may be iexplore */
- hinst = FindExecutable (param1, NULL, temp);
+ hinst = FindExecutable (thisDir, NULL, temp);
if ((INT_PTR)hinst < 32)
console = 0;
else
@@ -948,9 +962,10 @@ void WCMD_run_program (char *command, int called) {
st.cb = sizeof(STARTUPINFO);
init_msvcrt_io_block(&st);
- /* Launch the process and if a CUI wait on it to complete */
- status = CreateProcess (thisDir, command, NULL, NULL, TRUE,
- 0, NULL, NULL, &st, &pe);
+ /* Launch the process and if a CUI wait on it to complete
+ Note: Launching internal wine processes cannot specify a full path to exe */
+ status = CreateProcess (assumeInternal?NULL : thisDir,
+ command, NULL, NULL, TRUE, 0, NULL, NULL, &st, &pe);
if ((opt_c || opt_k) && !opt_s && !status
&& GetLastError()==ERROR_FILE_NOT_FOUND && command[0]=='\"') {
/* strip first and last quote characters and try again */
@@ -966,10 +981,10 @@ void WCMD_run_program (char *command, int called) {
errorlevel = 9009;
return;
}
- if (!console) errorlevel = 0;
+ if (!assumeInternal && !console) errorlevel = 0;
else
{
- if (!HIWORD(console)) WaitForSingleObject (pe.hProcess, INFINITE);
+ if (assumeInternal || !HIWORD(console)) WaitForSingleObject (pe.hProcess, INFINITE);
GetExitCodeProcess (pe.hProcess, &errorlevel);
if (errorlevel == STILL_ACTIVE) errorlevel = 0;
}