Jump to content

Recommended Posts

Posted (edited)

I'm trying to get a list of my drives in a batch to automate the process of assigning drive letters. When I type 'fsutil fsinfo drives' in comman line, I get a list of my drives.

C:\>fsutil fsinfo drives
Drives: A:\ C:\ D:\ E:\ F:\ G:\

But in a for loop, I only get the first drive letter. Anybody knows, what's wrong in the for construction?

C:\>for /F "tokens=*" %i in ('fsutil fsinfo drives') Do echo %i
C:\>echo Drives: A:\
Drives: A:\

Edited by Doc Symbiosis

Posted

Try this vbs script

Dim Act, Cnt, Drv, Fso, Rpt, Ts : Cnt = 0

Set Act = CreateObject("Wscript.shell")

Set Fso = CreateObject("Scripting.FileSystemObject") : Set Drv = Fso.Drives

Set Ts = Fso.CreateTextFile("Report_Drives.txt")

For Each strDrv In Drv

'If strDrv.DriveType = 2 Then '''' UNCOMMENT THIS TO ONLY LIST HARDRIVES OR PARTITIONS DONT FORGET TO DO THE END IF ALSO

Cnt = Cnt + 1

Ts.WriteLine strDrv & "\"

'End If

Next

Ts.WriteLine "Total Amount Of Drives = " & Cnt

Ts.close

Act.Run("Report_Drives.txt")

Posted

Well, there's nothing wrong with your construction (though you may want to use "tokens=1,*" if you just want the list of drive letters). The problem is that the character inbetween the drive letters is x000, which isn't a valid delimiter in the for command (nor have I been able, yet, to figure out what's going on there.)

What exactly are you tring to get and use it for? If I know that, I might be able to better help you along.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...