diskpart select by disk label - batch-file

I need to select a disk in WinPE using DISKPART by label. I found this but I think it's outdated:
#Echo %dbg%Off
::
:: Find External drive and set it active
:: Lists Disk Information using Diskpart
::
SetLocal EnableDelayedExpansion
:: Type the frst 11 characters of the label of the drive here.
Set _FindLabel=Recovery
Call :_InitVars "%_FindLabel%"
"%SystemRoot%\system32\FSUTIL.exe">Nul 2>&1||Goto _NotAdmin
Echo.
Echo.Please wait, gathering info on the installed drives
Echo.
>"%_Dscr1%" Echo.List disk
For /F "Tokens=2" %%I In ('Diskpart /S "%_Dscr1%"^|Findstr /I /R /C:"Disk [0-9]"') Do (
(Echo.Select Disk %%I
Echo.Detail Disk)>>"%_OFile1%"
)
For /F "Tokens=1,2,3*" %%I In ('Diskpart /S "%_OFile1%"^|Findstr /I /R /C:"Disk [0-9]" /C:"Volume [0-9]"') Do (
If /I %%I==Disk (
Set _Tmp=%%J:
) Else (
Set _Label=%%L
Set _Label=!_Label:~,11!
>>"%_OFile2%" Echo.!_Tmp!%%J:!_Label!
))
If Exist "%_OFile1%" Del "%_OFile1%"
For /F "Usebackq Tokens=1-3 Delims=:" %%I In ("%_OFile2%") Do (
Set _Label=%%K
Set _Label=!_Label:~,11!
If "!_Label!"=="%_FindLabel%" (Set _Disk=%%I) & (Set _Label=%%K) & Goto _FDisk
>>"%_OFile1%" Echo.Volume %%J on Disk %%I has the Label %%K
)
Echo.
Echo.There is no drive connected that has the label of "%_FindLabel%"
Echo.These are the currently connected volumes:
Type "%_OFile1%"
:_Exit
Echo.
Pause
Goto _Cleanup
:_FDisk
(Echo.Select disk %_Disk%
Echo.Select Partition 1
Echo.Active)>"%_Dscr1%"
Diskpart /S "%_Dscr1%"
:_Cleanup
For %%I In ("%_Dscr1%" "%_OFile1%" "%_OFile2%") Do Del %%I>Nul 2>&1
Goto :EOF
::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Subroutines
::::::::::::::::::::::::::::::::::::::::::::::::::::::
:_NotAdmin
Ver|Findstr /I /C:"Version 5">Nul
If %Errorlevel%==0 (Set _Tmp1=5) & (Set _Tmp=a Computer Administrator account)
Ver|Findstr /I /C:"Version 6">Nul
If %Errorlevel%==0 (Set _Tmp1=6) & (Set _Tmp=an Elevated Command Prompt)
Echo.
Echo.This program must be run from %_Tmp%.
If %_Tmp1%==6 Echo.Please Right click the file, then click Run as Administrator
Echo.Exiting program
Goto _Exit
:_InitVars
For /F "Tokens=1 Delims==" %%I In ('Set _ 2^>Nul') Do Set %%I=
Set _Dscr1=%temp%\dpscr1.txt
Set _OFile1=%temp%\_OFile1.txt
Set _OFile2=%temp%\_OFile2.txt
Set _FindLabel=%~1
Set _FindLabel=%_FindLabel:~,20%
Call :_Cleanup
When I run it, it returns:
Please wait, gathering info on the installed drives
There is no drive connected that has the label of "Recovery"
These are the currently connected volumes:
Volume 1 on Disk 0 has the Label NTFS Part
Volume 2 on Disk 0 has the Label NTFS Part
Volume 3 on Disk 1 has the Label WINPE
It's showing the Fs (filesystem), not the label.
Diskpart output (list volume)
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 D USBBOOT UDF DVD-ROM 329 MB Healthy
Volume 1 Windows NTFS Partition 40 GB Healthy
Volume 2 Recovery NTFS Partition 19 GB Healthy
Volume 3 Z WINPE FAT32 Removable 7632 MB Healthy
Not sure how to modify this to get it to select the Label column.

As there is missing valid drive letter in some lines of the Diskpart output (list volume, column ltr), then tokens in line #19
For /F "Tokens=1,2,3*" %%I In ('Diskpart /S "%_OFile1%"^|Findstr /I /R /C:"Disk [0-9]" /C:"Volume [0-9]"') Do (
display as follows (and we have our culprit now):
%%I %%J %%K %%L
Volume 0 D USBBOOT UDF DVD-ROM 329 MB ...
Volume 1 Windows NTFS Partition 40 GB Healthy
Volume 2 Recovery NTFS Partition 19 GB Healthy
Volume 3 Z WINPE FAT32 Removable 7632 MB ...
Therefore you could use next snippet code (instead of lines 19..26) in your script:
For /F "Tokens=1*" %%I In ('Diskpart /S "%_OFile1%"^|Findstr /I /R /C:"Disk [0-9]" /C:"Volume [0-9]"') Do (
If /I %%I==Disk (
Set _Tmp=%%J:
) Else (
Set _Label=%%J
Set _Label=!_Label:~10,11!
>>"%_OFile2%" Echo.!_Tmp!%%J:!_Label!
))
Care this change interferes _Tmp variable!

Related

USB drive Letter finder

I have this script that checks for a certain USB and then opens a file on it. However, now I need it to check only for the drive letter of the USB inserted so. However I don't really know how to do that and searches online returned nothing that could help me.
This is the script I have right now:
#echo off
:loop
if exist D:\ (goto Load) else (goto loop)
:Load
D:
start Loader1.exe
goto Finish
:Finish
exit
Is something like this that you are looking?
This will take over the task only on the Removable Disk and will be given the associated logical name of each for check if your file Loader1.exe is there for take next action.
See this link: How To List Drive Letters:
Value Meaning for drivetype in WMIC logicaldisk
0 Unknown
1 No root directory
2 Removable disk
3 Local disk
4 Network drive
5 Compact disk
6 RAM disk
wmic logicaldisk get caption,drivetype|find "2"
This Result Removable disk :
D: 2
E: 2
F: 2
G: 2
Caption = D:
DriveType = Removable disk == 2
After, and make sure the Loader1.exe file exist to start/run your command:
Driver:\Loader1.exe
The last part, time out (1 minute) to perform the next loop:
timeout 60 >nul && goto :loop
#echo off
:loop
for /f %%i in ('"wmic logicaldisk get caption,drivetype|find "2""')do if exist "%%~i\Loader1.exe" (
cd /d %%~i\ & start .\Loader1.exe && goto :Finish )
timeout 60 >nul & goto :loop)
:Finish
:: Or ::
#echo off
set "_cd=%cd%" && title <nul
:loop
for /f %%i in ('"wmic logicaldisk where drivetype=2 get name|find /v "Name""
')do if exist "%%~i\Loader1.exe" cd /d %%~i\ & start .\Loader1.exe & cd /d "%_cd%" & exit /b
timeout 60 >nul & goto :loop
Here's how to get the USB drive letter from any drive:
#echo off
for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,drivetype 2^>NUL`) do (
if %%l equ 2 ( echo %%i is a USB drive. )
)
Answer is not a duplicate of #scientist_7 I got it from Find USB Drive letter.

Retrieve PC Model from BIOS information

I'm writing a batch-file to update the BIOS on the PCs within my organization using the HP Bios Configuration Utility and I need a it to check a registry value in order to apply the appropriate configuration.
I found this code on the internet but can't get it to work:
#echo off
ECHO BIOS check HP
CD c:\Batch\bios\HP
reg query "HKEY_LOCAL_MACHINE\Hardware\Description\system\BIOS" /v "SystemProductName" | find /i "HP ProDesk 600 G3 PCI MT"
if errorlevel 0 (
echo HP ProDesk 600 G3 PCI MT
goto :end
)
reg query "HKEY_LOCAL_MACHINE\Hardware\Description\system\BIOS" /v "SystemProductName" | find /i "HP EliteDesk 800 G1 TWR"
if errorlevel 0 (
echo HP EliteDesk 800 G1 TWR
goto :end
)
:end
PAUSE
The error level doesn't work but it does look for the value.
This is what I'm using currently but systeminfo is taking too long to load on some PCs with a lot of hotfixes:
systeminfo > C:\Temp\Sysinf%t%.txt
CD c:\Batch\bios\HP
find "System Model: HP ProDesk 600 G3 PCI MT" C:\Temp\Sysinf%t%.txt
if %errorlevel%==0 goto :Leg_HP_ProDesk_600_G3_PCI_MT
find "System Manufacturer: HP EliteDesk 800 G1 TWR" C:\Temp\Sysinf%t%.txt
if %errorlevel%==0 goto :Leg_HP_EliteDesk_800_G1_TWR
:Leg_HP_ProDesk_600_G3_PCI_MT
BiosConfigUtility64.exe /setconfig:Leg_HP_ProDesk_600_G3_PCI_MT.txt /cspwdfile:"currentpassword.bin"
goto :Setpass
:Leg_HP_EliteDesk_800_G1_TWR
BiosConfigUtility64.exe /setconfig:Leg_HP_EliteDesk_800_G1_TWR.txt /cspwdfile:"currentpassword.bin"
goto :Setpass
:Setpass
BIOSConfigUtility64.exe /nspwdfile:"newpassword.bin" /cspwdfile:"currentpassword.bin"
I would expect something like this to work reasonably well, as long as BiosConfigUtility64.exe the .txt and .bin files are in C:\Batch\bios\HP:
#Set "SPN="&For /F "Tokens=2*" %%A In ('^""%__AppDir__%reg.exe" Query ^
"HKLM\Hardware\Description\system\BIOS" /V "SystemProductName" 2^>NUL^|^
"%__AppDir__%findstr.exe" /IC:"HP ProDesk 600 G3 PCI MT" /C:"HP EliteDesk 800 G1 TWR"^"'
)Do #Set "SPN=%%B"
#If Not Defined SPN Exit /B
#CD /D "C:\Batch\bios\HP" 2>NUL||Exit /B
#"BIOSConfigUtility64.exe" /SetConfig:"Leg_%SPN: =_%.txt" /cspwdfile:"currentpassword.bin"
#"BIOSConfigUtility64.exe" /nspwdfile:"newpassword.bin" /cspwdfile:"currentpassword.bin"
If you create all of your text files using the same naming format, (the returned name with spaces replaced with underscores and prefixed with Leg_), you could forget about the using findstr, just save the value and then check for an existing, matching .txt file:
#CD /D "C:\Batch\bios\HP" 2>NUL||Exit /B
#For /F "Tokens=2*" %%A In ('^""%__AppDir__%reg.exe" Query ^
"HKLM\Hardware\Description\system\BIOS" /V "SystemProductName" 2^>NUL^"')Do #Set "SPN=%%B"
#If Not Exist "Leg_%SPN: =_%.txt" Exit /B
#"BIOSConfigUtility64.exe" /SetConfig:"Leg_%SPN: =_%.txt" /cspwdfile:"currentpassword.bin"
#"BIOSConfigUtility64.exe" /nspwdfile:"newpassword.bin" /cspwdfile:"currentpassword.bin"

Batch conditional FOR loop nested IF

I'm trying to write a script that parses a text file to identify removable drives by Label. The goal is to create a copy script based on the found drives.
I'm able to parse the file but I can't seem to get the second pair of IF conditions to be true.
I may be misunderstanding how variables are evaluated in each loop of the FOR.
Thoughts appreciated.
EDIT: Expanding on the original request for clarity(it was late when I asked) The expanded goal is to identify one or many target drives to copy data from an SD card. Since the drives letter allocations vary from PC to PC and depend on which is plugged in first my idea was to use the labels as somewhat identifiable values and create a simple copy string along the lines of
XCOPY SourceDrive\*.jpg DestinationDrive1\<GetDate>\
XCOPY SourceDrive\*.jpg DestinationDrive2\<GetDate>\
End Edit
#echo off
cls
title "Detecting device drive letters..."
setlocal enabledelayedexpansion
set DestinationDrive1Found=
set DestinationDrive2Found=
set SourceDriveFound=
set SourceDrive=
set DestinationDrive1=
set DestinationDrive2=
echo Detecting device drive letters...
echo list volume > %systemdrive%\ListDrives.tmp
diskpart /s %systemdrive%\ListDrives.tmp > %systemdrive%\CurrentDrives.tmp
echo Checking drive IDs
FOR /F "skip=7 tokens=2-4" %%a IN (%systemdrive%\CurrentDrives.tmp) DO (
set "matchvar=%%c"
set "comparevar=!matchvar:DRIVE=!"
IF /I NOT "!comparevar!" == "%%c" IF "!DestinationDrive1Found!" NEQ 1 (
echo Drive %%b was found to be %%c and will be DESTINATION1
set DestinationDrive1Found=1
set DestinationDrive1=%%b )
IF /I NOT "!comparevar!" == "%%c" IF "!DestinationDrive1Found!" EQU 1 ( echo Drive %%b was found to be %%c and will be DESTINATION2
set DestinationDrive2Found=1
set DestinationDrive2=%%b )
)
File I'm parsing
Microsoft DiskPart version 10.0.10586
Copyright (C) 1999-2013 Microsoft Corporation.
On computer: NEWGLOOMWIN10
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 D DVD-ROM 0 B No Media
Volume 1 E Macintosh H HFS Partition 231 GB Healthy
Volume 2 C BOOTCAMP NTFS Partition 721 GB Healthy System
Volume 3 F TEAMXCAMRAX FAT Removable 1937 MB Healthy
Volume 4 G TEAMXDRIVEX NTFS Partition 465 GB Healthy
Volume 5 H TEAMYDRIVEY NTFS Partition 931 GB Healthy
Thanks to all who responded. Had #Mofi provided an answer I would have marked that response as the answer. In the end the removal of a four quote marks and the addition of an ELSE got me the answer I was looking for.
The script below gives me exactly what I'm after.
#echo off
cls
title "Detecting device drive letters..."
setlocal enabledelayedexpansion
set DestinationDrive1Found=
set DestinationDrive2Found=
set SourceDriveFound=
set SourceDrive=
set DestinationDrive1=
set DestinationDrive2=
echo Detecting device drive letters...
echo list volume > %systemdrive%\ListDrives.tmp
diskpart /s %systemdrive%\ListDrives.tmp > %systemdrive%\CurrentDrives.tmp
echo Checking drive IDs
FOR /F "skip=7 tokens=2-4" %%a IN (%systemdrive%\CurrentDrives.tmp) DO (
set "matchvar=%%c"
set "comparevar=!matchvar:CAMRA=!"
IF /I NOT "!comparevar!" == "%%c" (#echo Drive %%b was found to be %%c and will be SOURCE
set SourceDriveFound=1
set SourceDrive=%%b)
)
echo Checking drive IDs
FOR /F "skip=7 tokens=2-4" %%a IN (%systemdrive%\CurrentDrives.tmp) DO (
set "matchvar=%%c"
set "comparevar=!matchvar:DRIVE=!"
IF /I NOT "!comparevar!" == "%%c" IF !DestinationDrive1Found! NEQ 1 (
echo Drive %%b was found to be %%c and will be DESTINATION1
set DestinationDrive1Found=1
set DestinationDrive1=%%b
) ELSE (
IF /I NOT "!comparevar!" == "%%c" IF !DestinationDrive1Found! EQU 1 ( echo Drive %%b was found to be %%c and will be DESTINATION2
set DestinationDrive2Found=1
set DestinationDrive2=%%b ))
)
If you just want to set some variables to the drives allocated to any removable drive with the string DRIVE in it's 'label' then the following may provide you with an alternative not requiring elevation.
#Echo Off
For /F "UseBackQ Skip=1 Delims=" %%A In (`WMIC LogicalDisk Where^
"DriveType='2' And VolumeName Like '%%DRIVE%%'" Get Name`
) Do For /F %%B In ("%%A") Do Set/A "i+=1"&Call Set "_drv%%i%%=%%B"
Set _drv
Timeout -1
[Edits] - an example correctly stipulating a fixed drive
#Echo Off
For /F "UseBackQ Skip=1 Delims=" %%A In (`WMIC LogicalDisk Where^
"DriveType='3' And VolumeName Like '%%DRIVE%%'" Get Name`
) Do For /F %%B In ("%%A") Do Set/A "i+=1"&Call Set "_drv%%i%%=%%B"
Set _drv
Timeout -1
An example without stipulating the type of drive, (recommended based on comments).
#Echo Off
For /F "UseBackQ Skip=1 Delims=" %%A In (
`WMIC LogicalDisk Where "VolumeName Like '%%DRIVE%%'" Get Name`
) Do For /F %%B In ("%%A") Do Set/A "i+=1"&Call Set "_drv%%i%%=%%B"
Set _drv
Timeout -1

Batch file - Switch USB from read/write to read-only and vice versa

I was wondering if you can write a Batch file to make a USB from read/write to read-only and visa versa?
What the program should do is, if you double click on the batch file it searches for the USB drive, check if it is read/write or just read-only then swaps it to the other setting.
EDIT
I know the name of the USB and also the drive letter.
EDIT
I need this for work where we use USB drives to install programs on peoples laptops, we used CD's before, but they get lost inside.
Code would be appreciated, but directions to sites will help as well.
Tested and works flawlessly with the 4 drives I have tested.
I have the below for you if you would like. It requires 3 files though. The batch then 1 text file per each Read only or Read Write command. Simple setup but requires you to have an input, it will overwrite what ever it currently is to what ever you select.
Thanks JBin for advising that it needs to be run as Administrator, I forgot that was a thing.
cls
#Echo OFF
#Echo Toggle between read only and Read write
:choice
set /P c=Change to [R]ead Only or Read/[W]rite?
if /I "%c%" EQU "R" goto :read
if /I "%c%" EQU "W" goto :write
:read
DISKPART /s Readonly.txt
cls
#Echo -----------------------
#Echo ^| Disk is now READ ONLY ^|
#Echo -----------------------
#Echo.
goto :choice
:write
DISKPART /s Readwrite.txt
cls
#Echo ------------------------
#Echo ^| Disk is now READ WRITE ^|
#Echo ------------------------
#Echo.
goto :choice
Make two text files with the below in them. Name them what ever you like but dont forget to change the *.txt in the batch. This is also assuming you only have 1 usb device plugged into the computer
Readonly.txt file:
Sel disk 1
att dis set readonly
exit
Readwrite.txt file:
sel disk 1
att dis clear readonly
exit
It is possible to do this is Batch (via Diskpart command), but it will be VERY convoluted.
Anyways, this code detects removable drives (so floppies, I think, are included), creates a menu, then swaps the setting (read-only/read-write). It makes flash drives "write-protected", but I tested my code...
#echo off
setlocal enabledelayedexpansion
::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::Detect removable drives using DiskPart...
set "diskcnt=0"
for /f "tokens=1-2 delims= " %%A in (
'^(echo list disk^)^|diskpart^|findstr /ic:"Online"'
) do (
for /f "tokens=1-3 delims= " %%X in (
'^(echo select disk %%B^&echo detail disk^)^|diskpart^|findstr /ic:"Removable"'
) do (
set /a diskcnt+=1
set "vol!diskcnt!=%%B_%%Z:"
)
)
::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::After detecting drives, print a menu...
echo.The script detected %diskcnt% removable drive/s:
echo.
if %diskcnt% equ 0 echo No drives found.
for /l %%X in (1,1,%diskcnt%) do (
echo. %%X. Drive !vol%%X:~2,2!
)
echo.
:choice_loop
set /p "choice=Choose a Number: "
if !choice! geq 1 if !choice! leq %diskcnt% goto :doIt
goto choice_loop
::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::Get and set the setting...
:doIt
echo.
set "disknum=!vol%choice%:~0,1!"
for /f "tokens=1-2 delims=:" %%F in (
'^(echo select disk %disknum%^&echo attribute disk^)^|diskpart^|findstr /bic:"Read-Only"'
) do (
set "ro_state=%%G"&set "ro_state=!ro_state: =!"
)
if /i "%ro_state%" equ "No" (
(echo select disk %disknum%&echo attribute disk set readonly)|diskpart >nul
echo Drive !vol%choice%:~2,2! is now read-only from being read/write.
) else (
(echo select disk %disknum%&echo attribute disk clear readonly)|diskpart >nul
echo Drive !vol%choice%:~2,2! is now read/write from being read-only.
)
endlocal
pause
EDIT: My only concern here is that this is language dependent, so this will not work if the language is not English.
EDIT #2: Forgive me from misunderstanding the problem. If you already have a USB name to be modified, then try this: (Make sure there are no 2 flash drives with the same name that are plugged in at the same time.)
#echo off
::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::Put the name of flash drive here... (Case-sensitive)
set "name=[PUT NAME HERE]"
::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::Detect that removable drive using DiskPart...
set "disk_num="
for /f "tokens=1-2 delims= " %%A in (
'^(echo list disk^)^|diskpart^|findstr /ic:"Online"'
) do (
for /f "tokens=1-4 delims= " %%W in (
'^(echo select disk %%B^&echo detail disk^)^|diskpart^|findstr /ic:"Removable"'
) do (
if "%%Z"=="%name%" set "disk_num=%%B"
)
)
if not defined disk_num (
echo Flash drive '%name%' not found.
goto end_this
)
::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::Get and set the setting...
for /f "tokens=1-2 delims=: " %%F in (
'^(echo select disk %disk_num%^&echo attribute disk^)^|diskpart^|findstr /bic:"Read-Only"'
) do (
set "ro_state=%%G"
)
if /i "%ro_state%" equ "No" (
(echo select disk %disk_num%&echo attribute disk set readonly)|diskpart >nul
echo Flash drive '%name%' is now read-only from being read/write.
) else (
(echo select disk %disk_num%&echo attribute disk clear readonly)|diskpart >nul
echo Flash drive '%name%' is now read/write from being read-only.
)
:end_this
pause
exit /b
EDIT #3: For Windows 8 and up, Run the Batch Files as Administrator for this to work.

Finding which drives are connected to computer

I have a small side project I've been working on and i want to add an option to scan the computer and find which drives are connected and what they are(USB, Hard drive, Disc drive, SSD, etc.)
this is what i have so far.
echo off
:start
color 0a
cls
title Search
echo To search enter the drive and term you wish to search below.
echo ---------------------------------------------------------------------------
set inputdrive=
set /p inputdrive=Drive:
set input=
set /p input=Search:
dir %inputdrive%:\%input% /s /b
pause
echo search again?
set inputsearch=
set /p inputsearch=(Y/N)
if %inputsearch%==Y goto start
if %inputsearch%==N exit
I plan on adding an option to scan for connected drives at the beginning of the script.
You can use WMIC to get the info without the need for administrator rights.
Here is code that gives a nice listing of all available drives, including removable media drives that do not have any media installed:
#echo off
setlocal
set ^"driveTypes=^
0Unknown :^
1No Root Directory:^
2Removable Media :^
3Local Disk :^
4Network Drive :^
5CD/DVD :^
6RAM Disk :^"
echo Available Drives:
echo(
echo ID Drive Type Volume Name
echo -- ----------------- -----------
for /f "skip=1 tokens=1-3" %%A in (
'"wmic logicalDisk get DeviceID, DriveType, VolumeName"'
) do if "%%B" neq "" (
setlocal enableDelayedExpansion
for /f "delims=:" %%D in ("!driveTypes:*%%B=!") do (
endlocal
echo %%A %%D %%C
)
)
Just a bit more code will restrict the list to only drives that are available with media:
#echo off
setlocal
set ^"driveTypes=^
0Unknown :^
1No Root Directory:^
2Removable Media :^
3Local Disk :^
4Network Drive :^
5CD/DVD :^
6RAM Disk :^"
echo Available Drives:
echo(
echo ID Drive Type Volume Name
echo -- ----------------- -----------
for /f "skip=1 tokens=1-3" %%A in (
'"wmic logicalDisk get DeviceID, DriveType, VolumeName"'
) do if "%%B" neq "" dir %%A >nul 2>nul && (
setlocal enableDelayedExpansion
for /f "delims=:" %%D in ("!driveTypes:*%%B=!") do (
endlocal
echo %%A %%D %%C
)
)
fsutil fsinfo drives
fsutil fsinfo drivetype c:
But you need to have administrator rights to use it

Resources