Solved

Batch file to save current drive letter into a variable

Posted on 2006-07-13
3
3,909 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

697 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