Use proper file sharing parameters when opening files.
Fixed handling of 'if a == b' syntax in batch files.
This commit is contained in:
parent
8be60f8212
commit
36bf792fd7
@ -54,7 +54,8 @@ BATCH_CONTEXT *prev_context;
|
|||||||
strcpy (string, file);
|
strcpy (string, file);
|
||||||
CharLower (string);
|
CharLower (string);
|
||||||
if (strstr (string, ".bat") == NULL) strcat (string, ".bat");
|
if (strstr (string, ".bat") == NULL) strcat (string, ".bat");
|
||||||
h = CreateFile (string, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ,
|
||||||
|
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
SetLastError (ERROR_FILE_NOT_FOUND);
|
SetLastError (ERROR_FILE_NOT_FOUND);
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
|
@ -389,25 +389,28 @@ char condition[MAX_PATH], *command, *s;
|
|||||||
if (!lstrcmpi (condition, "errorlevel")) {
|
if (!lstrcmpi (condition, "errorlevel")) {
|
||||||
if (errorlevel >= atoi(WCMD_parameter (p, 1+negate, NULL))) test = 1;
|
if (errorlevel >= atoi(WCMD_parameter (p, 1+negate, NULL))) test = 1;
|
||||||
return;
|
return;
|
||||||
|
WCMD_parameter (p, 2+negate, &command);
|
||||||
}
|
}
|
||||||
else if (!lstrcmpi (condition, "exist")) {
|
else if (!lstrcmpi (condition, "exist")) {
|
||||||
if ((h = CreateFile (WCMD_parameter (p, 1+negate, NULL), GENERIC_READ, 0, NULL,
|
if ((h = CreateFile (WCMD_parameter (p, 1+negate, NULL), GENERIC_READ,
|
||||||
|
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
|
||||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) {
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) {
|
||||||
CloseHandle (h);
|
CloseHandle (h);
|
||||||
test = 1;
|
test = 1;
|
||||||
}
|
}
|
||||||
|
WCMD_parameter (p, 2+negate, &command);
|
||||||
}
|
}
|
||||||
else if ((s = strstr (p, "=="))) {
|
else if ((s = strstr (p, "=="))) {
|
||||||
s += 2;
|
s += 2;
|
||||||
if (!lstrcmpi (condition, WCMD_parameter (s, 0, NULL))) test = 1;
|
if (!lstrcmpi (condition, WCMD_parameter (s, 0, NULL))) test = 1;
|
||||||
|
WCMD_parameter (s, 1, &command);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WCMD_output ("Syntax error\n");
|
WCMD_output ("Syntax error\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (test != negate) {
|
if (test != negate) {
|
||||||
WCMD_parameter (p, 2+negate, &s);
|
command = strdup (command);
|
||||||
command = strdup (s);
|
|
||||||
WCMD_process_command (command);
|
WCMD_process_command (command);
|
||||||
free (command);
|
free (command);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ HANDLE h;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GetFullPathName ("\\autoexec.bat", sizeof(string), string, NULL);
|
GetFullPathName ("\\autoexec.bat", sizeof(string), string, NULL);
|
||||||
h = CreateFile (string, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (h != INVALID_HANDLE_VALUE) {
|
if (h != INVALID_HANDLE_VALUE) {
|
||||||
CloseHandle (h);
|
CloseHandle (h);
|
||||||
#if 0
|
#if 0
|
||||||
@ -181,7 +181,7 @@ char *whichcmd;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if ((p = strchr(cmd,'<')) != NULL) {
|
if ((p = strchr(cmd,'<')) != NULL) {
|
||||||
h = CreateFile (WCMD_parameter (++p, 0, NULL), GENERIC_READ, 0, NULL, OPEN_EXISTING,
|
h = CreateFile (WCMD_parameter (++p, 0, NULL), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
||||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
@ -383,7 +383,8 @@ char filetorun[MAX_PATH];
|
|||||||
if (strchr (param1, '.') == NULL) {
|
if (strchr (param1, '.') == NULL) {
|
||||||
strcpy (filetorun, param1);
|
strcpy (filetorun, param1);
|
||||||
strcat (filetorun, ".bat");
|
strcat (filetorun, ".bat");
|
||||||
h = CreateFile (filetorun, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
h = CreateFile (filetorun, GENERIC_READ, FILE_SHARE_READ,
|
||||||
|
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (h != INVALID_HANDLE_VALUE) {
|
if (h != INVALID_HANDLE_VALUE) {
|
||||||
CloseHandle (h);
|
CloseHandle (h);
|
||||||
WCMD_batch (param1, command, 0);
|
WCMD_batch (param1, command, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user