Maintaining correct working directory in batch files executed with 'Run as ...'
at HKEY_CLASSES_ROOT\cmdfile\shell\runas\command,
Instead of:
Code Block
%SystemRoot%\System32\cmd.exe /C "%1" %*
It should be:
Code Block
%SystemRoot%\System32\cmd.exe /C @cd /d "%W"&"%1" %*
... or something similar.
Otherwise, it changes the CWD to %SystemRoot%\System32\such thatmost batch files fail.
For compatibility's sake in current cmd files that launch as administrator, adding cd /d %~pd0 to the top works.
This solves my problem, but this should be fixed in the final 2008 release, right?
I think this also occurs in Vista.
November 12th, 2007 8:28pm