* Create your FREE website now *

Enumerate Local Drives

Tags:  

On the Fragmentation page I made a script using WMIC to enumerate local drives, then defragment each:


@echo off
setlocal
::Weekly defrag script; will defrag all locally attached hard disk partitions
set wmiccommand=wmic logicaldisk where "Description='Local Fixed Disk'" get caption
for /f "skip=1" %%a in ('%wmiccommand%') do call :DRIVECOMMANDS %%a
endlocal
goto :eof

:DRIVECOMMANDS
::each command here will be run against every local fixed
::disk (hard drive letter, C:, E:, etc) on the system
::CDroms, floppies, removable disks, network drives will NOT be included
::the driveletter is represented as %1
defrag %1


 


0 Comments
Post a comment



 RSS of this page

Written by:   Written by:   Version:   Last Edited By:   Modified