batch file quesiton |
![]() ![]() |
batch file quesiton |
Nov 20 2008, 06:51 PM
Post
#1
|
|
|
New Member ![]() Posts: 6 OS: XP |
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? |
|
|
Nov 26 2008, 01:01 AM
Post
#2
|
|
![]() TA Moderator 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 |
|
|
![]() ![]() |
Similar Topics
| Topic Title | Replies / Views | Topic Information | |||||
|---|---|---|---|---|---|---|---|
![]() |
4 / 1,160 | 3rd December 2008 - 11:46 PM Tender_Prey started - last by jnicholls08 |
|||||
![]() |
5 / 1,654 | 18th August 2008 - 11:43 AM AliL started - last by Ax238 |
|||||
![]() |
4 / 495 | 16th October 2008 - 05:31 PM pr0n started - last by pr0n |
|||||
![]() |
1 / 203 | 17th December 2008 - 05:50 PM aesvolleys started - last by Ax238 |
|||||
|
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. |