Advertisement
Guest User

Physical Drives.bat

a guest
Nov 28th, 2021
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.52 KB | None | 0 0
  1. @echo off &cls
  2. mode con: cols=200 lines=40  &color f0
  3. Setlocal
  4.  
  5. :: - Get Optical Drive(s) Information -----------------------------------------------
  6. for /f "skip=2 tokens=2,3 delims=," %%i in (
  7.   '%SystemRoot%\System32\wbem\wmic.exe logicaldisk where "drivetype=5" get Caption^ /format:csv'
  8. ) Do (
  9.     set "optical_drive_letter=%%i"
  10. )
  11.  
  12. for /f "tokens=2,3 delims=," %%a in (
  13.   '%SystemRoot%\System32\wbem\wmic.exe cdrom where "mediatype!=11" get name^,mediatype /format:csv'
  14. ) Do (
  15.   set "optical_drive_type=%%a"
  16.   set "optical_drive_name=%%b"
  17. )
  18.  
  19. ::echo( Volume %optical_drive_letter%\
  20. ::echo( %optical_drive_description%/%optical_drive_type% (%optical_drive_name%)
  21. :: ------------------------------------------------------------------------------
  22.  
  23. echo( Volume %optical_drive_letter%\
  24. echo( %optical_drive_type% (%optical_drive_name%)
  25. echo(
  26.  
  27. call :setESC
  28.  
  29. call :hdd-info
  30.  
  31. endlocal
  32. echo. Press any key to exit &>nul timeout /t -1 &exit /B
  33.  
  34. REM - Setup ANSI Escape Character ------------------------------------------------
  35. :setESC
  36. for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
  37.   set ESC=%%b
  38.   exit /B 0
  39. )
  40. REM ------------------------------------------------------------------------------
  41.  
  42. :: - Get Storage / HDD Info ------------------------------------------------------
  43. :hdd-info
  44. :: Enable use of Unicode symbols
  45. chcp 65001 >nul
  46. set "GB=1073741824"
  47. for /f "skip=1 delims=" %%i in ('%SystemRoot%\System32\wbem\wmic.exe logicaldisk get deviceid^,freespace^,size^') do (for /f "tokens=1-3" %%j in ("%%i") do call :output %%j %%k %%l)
  48. :: Disable Unicode symbols
  49. chcp 1252 >nul
  50. goto :eof
  51.  
  52. :output
  53. if "%3"=="" (
  54.  :: echo. Volume %optical_drive_letter%\ - %optical_drive_type% ^(%optical_drive_name%^)
  55. goto :eof
  56. )
  57.  
  58. for /f "tokens=1-4" %%i in (
  59.   'mshta vbscript:Execute("CreateObject(""Scripting.FileSystemObject"").GetStandardStream(1).Write(FormatNumber(%3/%GB%, 2) & "" "" & FormatNumber((%3-%2)/%GB%, 2) & "" "" & FormatNumber(%2/%GB%, 2) & "" "" & Round((%3-%2)*50/%3)):Close"^)'
  60. ) do (
  61.   set "size=%%i"
  62.   set "used=%%j"
  63.   set "free=%%k"
  64.   set /a "nUsed=%%l, nFree=50-%%l"
  65. )
  66.  
  67. echo( Volume %1\
  68. echo( Total Size          : %size:~-10%GB
  69. echo( Used Space          : %used:~-10%GB
  70. echo( Free Space          : %free:~-10%GB
  71. for /l %%i in (1 1 %nUsed%) do <nul set /p "=%ESC%[91m▓%ESC%[30m"
  72. for /l %%i in (1 1 %nFree%) do <nul set /p "=%ESC%[92m▓%ESC%[30m"
  73. echo( &echo(
  74. goto :eof
  75. :: ------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement