Let wcmd handle .cmd files like .bat files.

This commit is contained in:
Stefan Leichter 2003-03-25 00:33:56 +00:00 committed by Alexandre Julliard
parent c9fda6faeb
commit a127ad1cd1
3 changed files with 18 additions and 4 deletions

View File

@ -264,7 +264,7 @@ static UINT SHELL_FindExecutable(LPCSTR lpPath, LPCSTR lpFile, LPCSTR lpOperatio
/* See if it's a program - if GetProfileString fails, we skip this
* section. Actually, if GetProfileString fails, we've probably
* got a lot more to worry about than running a program... */
if (GetProfileStringA("windows", "programs", "exe pif bat com",
if (GetProfileStringA("windows", "programs", "exe pif bat cmd com",
buffer, sizeof(buffer)) > 0)
{
UINT i;

View File

@ -47,15 +47,22 @@ extern DWORD errorlevel;
void WCMD_batch (char *file, char *command, int called) {
HANDLE h;
#define WCMD_BATCH_EXT_SIZE 5
HANDLE h = INVALID_HANDLE_VALUE;
char string[MAXSTRING];
char extension[][WCMD_BATCH_EXT_SIZE] = {".bat",".cmd"};
int i;
BATCH_CONTEXT *prev_context;
for(i=0; (i<(sizeof(extension)/WCMD_BATCH_EXT_SIZE)) &&
(h == INVALID_HANDLE_VALUE); i++) {
strcpy (string, file);
CharLower (string);
if (strstr (string, ".bat") == NULL) strcat (string, ".bat");
if (strstr (string, extension[i]) == NULL) strcat (string, extension[i]);
h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
}
if (h == INVALID_HANDLE_VALUE) {
SetLastError (ERROR_FILE_NOT_FOUND);
WCMD_print_error ();

View File

@ -366,9 +366,16 @@ char filetorun[MAX_PATH];
return;
}
}
if ((strchr (param1, '.') == NULL) || (strstr (param1, ".cmd") != NULL)) {
if (SearchPath (NULL, param1, ".cmd", sizeof(filetorun), filetorun, NULL)) {
WCMD_batch (filetorun, command, 0);
return;
}
}
}
else { /* Explicit path given */
if (strstr (param1, ".bat") != NULL) {
if ((strstr (param1, ".bat") != NULL) ||
(strstr (param1, ".cmd") != NULL)) {
WCMD_batch (param1, command, 0);
return;
}