Batch file to save current drive letter into a variable

I would like to be able to do something like this: command %driveletter% . Any help is appreciated.

Thanks!
gromulAsked:
Who is Participating?
 
rage419Connect With a Mentor Commented:
How about using the %cd% variable and set? Seems to work...

set bob=%cd:~0,1%

0
 
Steve KnightIT ConsultancyCommented:
Or for NT4 I have had to use this as %CD% doesn't work until 2000 (which therefore works on NT/2000/XP/2003):

for /f "tokens=*" %A in ('CD') do set DRIVE=%~dA
0
 
Here2HelpCommented:
Hey.

If you are using XP you can use these:

%Homepath%
%Systemdrive%
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.