wcmd: strip quotes around executable and retry on error wcmd currently gives a 'File not found' error for the command: `./wine wcmd /c "notepad test.txt"` because it only tries to execute the program "notepad text.txt". In XP, cmd.exe starts notepad.exe with test.txt as its argument upon not finding a "notepad text.txt" executable. Thomas Kho --- programs/wcmd/wcmdmain.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/programs/wcmd/wcmdmain.c b/programs/wcmd/wcmdmain.c index 1af01eb..7c2a387 100644 --- a/programs/wcmd/wcmdmain.c +++ b/programs/wcmd/wcmdmain.c @@ -614,6 +614,20 @@ char filetorun[MAX_PATH]; status = CreateProcess (NULL, command, NULL, NULL, TRUE, 0, NULL, NULL, &st, &pe); + if (!status && GetLastError() == ERROR_FILE_NOT_FOUND && command[0]=='"') { + /* strip first set of unescaped quotes and try again */ + char *src = command, *dest = command; + src++; + while(*src!='"') { /* find matching " */ + if (*src=='\\') /* skip escaped character */ + *dest++ = *src++; + *dest++=*src++; + } + src++; + while((*dest++=*src++)!='\0') ; /* empty body */ + status = CreateProcess (NULL, command, NULL, NULL, TRUE, + 0, NULL, NULL, &st, &pe); + } if (!status) { WCMD_print_error (); return;