Welcome Guest ( Log In | Join )

Discover the best free computer help!
Learn more about Geeks to Go by taking the tour. Want to ask a question, reply to a topic, or remove all advertising? It's easy, fast and free. Join today!
Spyware, virus, trojan, fake security or privacy alerts? Please start with our malware cleaning guide.
     
 
Reply to this topicStart new topic
batch file quesiton
Dimension
post Nov 20 2008, 06:51 PM
Post #1


New Member
*
Posts: 6
OS: XP



I am currently tinkering with a piece of code which pulls up the drives connected to my pc. this works fine however what I would like ideally is a number list of each drive which is what i'm currently trying to work out.

CODE
@echo off & setlocal enableextensions

for %%d in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do fsutil fsinfo drivetype %%d: | find /v "No such Root Directory"

::endlocal & goto :EOF

pause


eg - it current displays:

C: - Fixed Drive
D: - CD-ROM Drive
F: - CD-ROM Drive

I would like:

1. C: - Fixed Drive
2. D: - CD-ROM Drive
3. F: - CD-ROM Drive

Please select a drive from the list:


Is this possible?
Go to the top of the page
 
+Quote Post
Ax238
post Nov 26 2008, 01:01 AM
Post #2


TA Moderator
Group Icon
Posts: 1,281
From: SET HOMEPATH
OS: Windows 95/98/2000/XP/Vista



Yep, it's possible. I took a little time putting this all together, you'll have to let me know if you have any questions or problems.

CODE
@echo off
setlocal enabledelayedexpansion

set tf=x
set /a number=0
for /f "tokens=1* delims= " %%a in ('fsutil fsinfo drives ^| find "\"') do call :process %%a %%b
del %tf%

:UserInput
:: Asks for and checks user input, based on drive variables
:: If nothing is selected, processing is terminated
:: If invalid value is selected, it loops back to the beginning
set choice=
set /p choice=Please select a drive from the list:
if "%choice%"=="" Echo Exiting... & goto :eof

for /f "tokens=2 delims== " %%a in ('set drive%choice% 2^>^&1') do (
    if "%%a"=="variable" (
        Echo Invalid option selected, please try again
        goto :UserInput
    ) else (
        set choice=%%a
    )
)
:: At this point, we should have a valid drive stored in the %choice% variable

endlocal
goto :eof

:process
:: Gets the information for each drive, sets the drive number variables
if "%1"=="" goto :eof
set /a number+=1
if /i "%1" NEQ "Drives:" (
    set drive%number%=%1
    fsutil fsinfo drivetype %1 > %tf%
) else (
    set drive%number%=%2
    fsutil fsinfo drivetype %2 > %tf%
)
set /p drivetype=<%tf%
echo %number%. %drivetype%


Regards,

Ax
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies / Views Topic Information
No New Posts   4 / 1,160 3rd December 2008 - 11:46 PM
Tender_Prey started - last by jnicholls08
No New Posts   5 / 1,654 18th August 2008 - 11:43 AM
AliL started - last by Ax238
No New Posts   4 / 495 16th October 2008 - 05:31 PM
pr0n started - last by pr0n
No New Posts   1 / 203 17th December 2008 - 05:50 PM
aesvolleys started - last by Ax238

RSS Time is now: 7th January 2009 - 11:08 PM
Advertisements do not imply our endorsement of that product or service. The forum is run by volunteers who donate their time and expertise. We make every attempt to ensure that the help and advice posted is accurate and will not cause harm to your computer. However, we do not guarantee that they are accurate and they are to be used at your own risk.