1

In Windows 7 the DOS variable %cd% returns the current drive. However when BAT file is started with admin rights (Run as administrator), then %cd% returns "C:\Windows\System32" instead of the current drive. Please, help.

Ludmil
  • 19
  • 2
  • Possible duplicate of [What is the best way to do a substring in a batch file?](https://stackoverflow.com/questions/636381/what-is-the-best-way-to-do-a-substring-in-a-batch-file) – Strikegently Oct 30 '17 at 16:24
  • _"In Windows 7 the DOS variable %cd% returns the current drive."_ No, it returns the `C` urrent `D` irectory. – underscore_d Oct 30 '17 at 16:32
  • Possible duplicate of [How do I test the current drive letter in a batch file?](https://stackoverflow.com/questions/866623/how-do-i-test-the-current-drive-letter-in-a-batch-file) or [Windows Batch Script Get Current Drive name](https://stackoverflow.com/questions/5811966/windows-batch-script-get-current-drive-name) – underscore_d Oct 30 '17 at 16:33

1 Answers1

1

%CD:~0,3% should give just the first three characters (C:)...

IAmCoder
  • 2,674
  • 1
  • 21
  • 40