Author: peterw
Date: Fri Feb 1 17:15:41 2008
New Revision: 32074
URL:
http://svn.reactos.org/svn/reactos?rev=32074&view=rev
Log:
- Make dp0 give the directory the batch was run from instead of the current directory.
Modified:
trunk/reactos/base/shell/cmd/batch.c
trunk/reactos/base/shell/cmd/batch.h
trunk/reactos/base/shell/cmd/cmd.c
Modified: trunk/reactos/base/shell/cmd/batch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/batch.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/batch.c (original)
+++ trunk/reactos/base/shell/cmd/batch.c Fri Feb 1 17:15:41 2008
@@ -220,6 +220,7 @@
BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
{
HANDLE hFile;
+ LPTSTR tmp;
SetLastError(0);
hFile = CreateFile (fullname, GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ |
FILE_SHARE_DELETE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL |
@@ -269,6 +270,8 @@
}
bc->hBatchFile = hFile;
+ tmp = _tcsrchr(fullname, '\\');
+ _tcsncpy(bc->BatchFilePath, fullname, ((_tcslen(fullname) - _tcslen(tmp)) + 1));
SetFilePointer (bc->hBatchFile, 0, NULL, FILE_BEGIN);
bc->bEcho = bEcho; /* Preserve echo across batch calls */
bc->shiftlevel = 0;
Modified: trunk/reactos/base/shell/cmd/batch.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/batch.h?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/batch.h (original)
+++ trunk/reactos/base/shell/cmd/batch.h Fri Feb 1 17:15:41 2008
@@ -12,6 +12,7 @@
struct tagBATCHCONTEXT *prev;
LPWIN32_FIND_DATA ffind;
HANDLE hBatchFile;
+ TCHAR BatchFilePath[MAX_PATH];
LPTSTR forproto;
LPTSTR params;
LPTSTR raw_params; /* Holds the raw params given by the input */
Modified: trunk/reactos/base/shell/cmd/cmd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.c?rev=3…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmd.c (original)
+++ trunk/reactos/base/shell/cmd/cmd.c Fri Feb 1 17:15:41 2008
@@ -1300,11 +1300,8 @@
if ( varNameLen )
*varNameLen = 4;
varName += 2;
- if ( !GrowIfNecessary ( MAX_PATH, &ret, &retlen ) )
- return NULL;
- GetCurrentDirectory(MAX_PATH, ret);
- }
- return ret;
+ return bc->BatchFilePath;
+ }
case _T('0'):
case _T('1'):
case _T('2'):