Link to home
Start Free TrialLog in
Avatar of apendes
apendes

asked on

batch script to determine hard disk

Hello Experts,

I'm writting a script to determine the fixed drives in a computer and put the output in a text file. There is a simple sample of my test but didn't work.

fsutil fsinfo drives|findstr /I /V "Units: " > c:\Units.txt
for /F "eol=; tokens=* delims= " %%i in (Units.txt) do fsutil fsinfo drivetype %%i|findstr /I /X "%%i- Fixed Drive" > HDisks.txt

Any help?? Thanks!
Avatar of gurutc
gurutc
Flag of United States of America image

Hi,

Thinking about this question, I come up with a couple of conclusions, possibly wrong.

First, you probably won't have more than 4 physical drives to check, so you can limit your search to drives c: through f: or so.

Second, you can make sure you don't have a ton more local drives by checking the lastdrive environment variable.

Third, other options may be available, depending on whether this is true DOS or a command shell.

Fourth, brute force, ie change to each drive letter and check for an error-level condition.

Good Luck,

- gurutc
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of apendes
apendes

ASKER

Its a very clear method to acomplish my request.
Thanks