I'm working on a batch that can get the drive letters and drive types via fsutil fsinfo ... but I'm stuck with the if logic that follows. If the drive type is fixed, I'd like to run a defrag utility called dirms.exe. Once this is solved, I'd have one batch file that can run as a scheduled task on every machine, regardless of drive configurations. Right now I'm redirecting to a text file, as I'm not sure what to do next.
So far I can get the drive letters and drive type:
rem set log file name and location
rem get drive letters
for /f "tokens=*" %%a in ('fsutil fsinfo drives^|find /v ""') do (
call set drlist=%%drlist%% %%dr:~-3%%
rem use drive letters to get drive type
for %%a in (%drlist%) do fsutil fsinfo drivetype %%a >> %log%
rem now defrag fixed drives and exclude optical and remote/network drives
The text file %log% contains the following:
C:\ - Fixed Drive
D:\ - CD-ROM Drive
M:\ - Remote/Network Drive
How do I run dirms.exe only on the fixed drive? I've read a bit about IF and ELSE, but I'm quite confused. Can someone nudge me in the right direction?