Solved

Batch file to save current drive letter into a variable

Posted on 2006-07-13
3
3,904 Views
Last Modified: 2012-05-05
I would like to be able to do something like this: command %driveletter% . Any help is appreciated.

Thanks!
0
Comment
Question by:gromul
3 Comments
 
LVL 4

Accepted Solution

by:
rage419 earned 500 total points
ID: 17105353
How about using the %cd% variable and set? Seems to work...

set bob=%cd:~0,1%

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17106326
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
 
LVL 8

Expert Comment

by:Here2Help
ID: 17109713
Hey.

If you are using XP you can use these:

%Homepath%
%Systemdrive%
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question