Page 1 of 1
drives
Posted: 26 Dec 2010 12:07
by Mohammad_Dos
I want to write a batch file that save my drives information into a txt file. for example I want my batch file write these lines into "c:\drive.txt" as output:
Code: Select all
you have 4 Hard drives:
c:\ , d:\ , e:\ , f:\
and 2 cd/dvd drives:
g:\ , h:\
and 1 floppy drive:
a:\
sorry for my english

Re: drives
Posted: 26 Dec 2010 13:20
by rfpd
Try this code:
Code: Select all
@echo off
wmic logicaldisk get caption,drivetype > C:\drive.txt
Output:Caption DriveType
C: 3
D: 3
E: 3
F: 5
H: 5
3 means hard drive
5 meand cd/drive drive
I hope i helped.
Regards, rfpd.
Re: drives
Posted: 26 Dec 2010 19:24
by aGerman
Another possibility:
Code: Select all
@echo off &setlocal
for /f "tokens=1*" %%a in ('fsutil fsinfo drives') do (
for %%c in (%%b) do (
fsutil fsinfo drivetype %%c
)
)
pause
Run as administrator on Win7.
Regards
aGerman
Re: drives
Posted: 29 Dec 2010 10:44
by Mohammad_Dos
rfpd wrote:Try this code:
Code: Select all
@echo off
wmic logicaldisk get caption,drivetype > C:\drive.txt
Output:Caption DriveType
C: 3
D: 3
E: 3
F: 5
H: 5
3 means hard drive
5 meand cd/drive drive
I hope i helped.
Regards, rfpd.
and 2 means flash memory or ram reader or external usb drive
thank u
Re: drives
Posted: 29 Dec 2010 10:48
by Mohammad_Dos
aGerman wrote:Another possibility:
Code: Select all
@echo off &setlocal
for /f "tokens=1*" %%a in ('fsutil fsinfo drives') do (
for %%c in (%%b) do (
fsutil fsinfo drivetype %%c
)
)
pause
Run as administrator on Win7.
Regards
aGerman
but I have win xp
Re: drives
Posted: 29 Dec 2010 10:59
by aGerman
Well then a simple double click should run the script. Didn't you try it?
Regards
aGerman
Re: drives
Posted: 01 Jan 2011 04:17
by Mohammad_Dos
aGerman wrote:Well then a simple double click should run the script. Didn't you try it?
Regards
aGerman
yes, of course
dont work in win xp
I have a question:
how to replace these words in the c:\Drive.txt ?
Caption DriveType
C: 3 "3"----->"Hard Disk Drive"
D: 3 "3"----->"Hard Disk Drive"
E: 3 "3"----->"Hard Disk /Drive"
F: 5 "5"----->"CD/DVD Drive"
H: 5 "5"----->"CD/DVD Drive"
L: 2 "2"----->"External USB Drive"
Re: drives
Posted: 01 Jan 2011 08:45
by aGerman
Mohammad_Dos wrote:aGerman wrote:Well then a simple double click should run the script. Didn't you try it?
Regards
aGerman
yes, of course
dont work in win xp
Strange

I remember that it worked for me on XP.
Mohammad_Dos wrote:I have a question:
how to replace these words in the c:\Drive.txt ?
You could already write the Drive.txt file with the replaced type numbers.
Code: Select all
@echo off &setlocal enabledelayedexpansion
set "DriveType_1=Unknown"
set "DriveType_2=Removeable Drive"
set "DriveType_3=Local Hard Disk"
set "DriveType_4=Network Hard Disk"
set "DriveType_5=Compact Disc"
set "DriveType_6=RAM Disk"
(
for /f "tokens=1,2" %%a in ('wmic logicaldisk get caption^,drivetype') do (
set "Drive=%%a "
set "TypeName="
set "TypeName=!DriveType_%%b!"
if not defined TypeName set "TypeName=%%b"
echo(!Drive:~0,8!!TypeName!
)
)>C:\Drive.txt
Regards
aGerman
Re: drives
Posted: 02 Jan 2011 07:55
by Mohammad_Dos
aGerman wrote:Another possibility:
Code: Select all
@echo off &setlocal
for /f "tokens=1*" %%a in ('fsutil fsinfo drives') do (
for %%c in (%%b) do (
fsutil fsinfo drivetype %%c
)
)
pause
Run as administrator on Win7.
Regards
aGerman
now worked!!!!
but not completly:
Re: drives
Posted: 02 Jan 2011 08:04
by Mohammad_Dos
aGerman wrote:Code: Select all
@echo off &setlocal enabledelayedexpansion
set "DriveType_1=Unknown"
set "DriveType_2=Removeable Drive"
set "DriveType_3=Local Hard Disk"
set "DriveType_4=Network Hard Disk"
set "DriveType_5=Compact Disc"
set "DriveType_6=RAM Disk"
(
for /f "tokens=1,2" %%a in ('wmic logicaldisk get caption^,drivetype') do (
set "Drive=%%a "
set "TypeName="
set "TypeName=!DriveType_%%b!"
if not defined TypeName set "TypeName=%%b"
echo(!Drive:~0,8!!TypeName!
)
)>C:\Drive.txt
Regards
aGerman
good. output:
Code: Select all
Please wait
A: Removeable Drive
C: Local Hard Disk
D: Local Hard Disk
E: Local Hard Disk
F: Local Hard Disk
G: Compact Disc
H: Local Hard Disk
I: Compact Disc
K: Removeable Drive
but I dont want "
please wait". is it possible?
Re: drives
Posted: 02 Jan 2011 08:43
by aGerman
Honestly I have no idea where this line is comming from.
My head line is
Caption DriveType
Probably the wmic command is outputting this line while it collects the data. You could try to skip the first line.
Code: Select all
@echo off &setlocal enabledelayedexpansion
set "DriveType_1=Unknown"
set "DriveType_2=Removeable Drive"
set "DriveType_3=Local Hard Disk"
set "DriveType_4=Network Hard Disk"
set "DriveType_5=Compact Disc"
set "DriveType_6=RAM Disk"
(
for /f "skip=1 tokens=1,2" %%a in ('wmic logicaldisk get caption^,drivetype') do (
set "Drive=%%a "
set "TypeName="
set "TypeName=!DriveType_%%b!"
if not defined TypeName set "TypeName=%%b"
echo(!Drive:~0,8!!TypeName!
)
)>C:\Drive.txt
Regards
aGerman
Re: drives
Posted: 03 Jan 2011 04:17
by Mohammad_Dos
worked
output:
Code: Select all
A: Removeable Drive
C: Local Hard Disk
D: Local Hard Disk
E: Local Hard Disk
F: Local Hard Disk
G: Compact Disc
H: Local Hard Disk
I: Compact Disc