?
Solved

Batch file to save current drive letter into a variable

Posted on 2006-07-13
3
Medium Priority
?
3,918 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 2000 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

762 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