[PATCH 1/8] CMD.exe: Attempt launch even if fails to locate program

Alexandre Julliard julliard at winehq.org
Mon Apr 2 04:46:17 CDT 2007


Jason Edmeades <us at edmeades.me.uk> writes:

> +  /* Internal programs wont be picked up by this, so try one final
> +     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           */
> +  ZeroMemory (&st, sizeof(STARTUPINFO));
> +  st.cb = sizeof(STARTUPINFO);
> +  init_msvcrt_io_block(&st);
> +
> +  /* Launch the process and assume CUI so wait on it to complete */
> +  status = CreateProcess (NULL, 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 */
> +    WCMD_opt_s_strip_quotes(command);
> +    opt_s=1;
> +    WCMD_run_program(command, called);
> +    return;
> +  }
> +
> +  /* If it still fails, give up */
> +  if (!status) {
> +    SetLastError(ERROR_FILE_NOT_FOUND);
> +    WCMD_print_error ();
> +    /* If a command fails to launch, it sets errorlevel 9009 - which
> +       does not seem to have any associated constant definition     */
> +    errorlevel = 9009;
> +    return;
> +  }
> +
> +  /* Wait for it to end */
> +  WaitForSingleObject (pe.hProcess, INFINITE);
> +  GetExitCodeProcess (pe.hProcess, &errorlevel);
> +  if (errorlevel == STILL_ACTIVE) errorlevel = 0;
> +  CloseHandle(pe.hProcess);
> +  CloseHandle(pe.hThread);

You should use the existing CreateProcess code instead of duplicating
it all.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list