cmd: %~dp0 should expand to the directory containing the batch file, not the current directory.

This commit is contained in:
Dan Kegel 2010-02-02 16:56:38 -08:00 committed by Alexandre Julliard
parent 4509d9aa10
commit 60fe4dae7a
2 changed files with 6 additions and 1 deletions

View File

@ -91,6 +91,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, int called, WCHAR *startLabel, HAN
prev_context = context;
context = LocalAlloc (LMEM_FIXED, sizeof (BATCH_CONTEXT));
context -> h = h;
context->batchfileW = WCMD_strdupW(string);
context -> command = command;
memset(context -> shift_count, 0x00, sizeof(context -> shift_count));
context -> prev_context = prev_context;
@ -122,6 +123,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, int called, WCHAR *startLabel, HAN
* to the caller's caller.
*/
HeapFree(GetProcessHeap(), 0, context->batchfileW);
LocalFree (context);
if ((prev_context != NULL) && (!called)) {
prev_context -> skip_rest = TRUE;
@ -382,7 +384,9 @@ void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable, WCHAR *forValu
if (lastModifier == firstModifier) return; /* Invalid syntax */
/* Extract the parameter to play with */
if ((*lastModifier >= '0' && *lastModifier <= '9')) {
if (*lastModifier == '0') {
strcpyW(outputparam, context->batchfileW);
} else if ((*lastModifier >= '1' && *lastModifier <= '9')) {
strcpyW(outputparam, WCMD_parameter (context -> command,
*lastModifier-'0' + context -> shift_count[*lastModifier-'0'], NULL));
} else {

View File

@ -118,6 +118,7 @@ void WCMD_execute (WCHAR *orig_command, WCHAR *redirects, WCHAR *parameter,
typedef struct {
WCHAR *command; /* The command which invoked the batch file */
HANDLE h; /* Handle to the open batch file */
WCHAR *batchfileW; /* Name of same */
int shift_count[10]; /* Offset in terms of shifts for %0 - %9 */
void *prev_context; /* Pointer to the previous context block */
BOOL skip_rest; /* Skip the rest of the batch program and exit */