Created
July 9, 2022 18:53
-
-
Save DanielAdeniji/e7d1a1129f13fbabd22c3dab06e7fff1 to your computer and use it in GitHub Desktop.
DOS - Batch - Get Drive Letter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem Get current drive letter in CMD | |
rem https://stackoverflow.com/questions/21069787/get-current-drive-letter-in-cmd | |
setlocal | |
rem get contextual information | |
set "_contextualDrive=%cd:~0,2%" | |
set "_contextualFolder=%cd%" | |
rem get script information | |
set "_scriptDrive=%~d0" | |
set "_scriptFolder=%~p0" | |
set "_scriptFullPath=%~dp0" | |
rem display empty line | |
echo. | |
echo The Contexual Drive is %_contextualDrive% | |
echo The Contextual Folder Is %_contextualFolder% | |
rem display empty line | |
echo. | |
echo The Script Drive Is %_scriptDrive% | |
echo The Script Folder Is %_scriptFolder% | |
echo The Script Full Path Is %_scriptFullPath% | |
rem display empty line | |
echo. | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment