CD-ROMのドライブ名を取得

CD-ROMのドライブ名を取得

バッチ

コマンド:


wmic CDROM get /value | findstr "^Id="

実行例:


C:\>wmic CDROM get /value | findstr "^Id="

Id=D:


Powershell

コマンド:


Set wbem = WScript.CreateObject("WbemScripting.SWbemLocator") 
Set s = wbem.ConnectServer 
Set q = s.ExecQuery("Select * From Win32_CDROMDrive") 

For Each c In q

 WScript.Echo c.Drive 
 WScript.Echo c.Description 
 WScript.Echo c.MediaType 
Next 

Set c = Nothing
Set q = Nothing
Set s = Nothing
Set wbem = Nothing


実行例:


D:

CD-ROM ドライブ

DVD-ROM


コマンドサンプル一覧