November 12, 200520 yr 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 drivesDrives: 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 %iC:\>echo Drives: A:\Drives: A:\ Edited November 12, 200520 yr by Doc Symbiosis
November 12, 200520 yr Try this vbs script Dim Act, Cnt, Drv, Fso, Rpt, Ts : Cnt = 0Set 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 ALSOCnt = Cnt + 1Ts.WriteLine strDrv & "\"'End IfNextTs.WriteLine "Total Amount Of Drives = " & CntTs.closeAct.Run("Report_Drives.txt")
November 12, 200520 yr 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.
November 12, 200520 yr Author I want automatically assign drive letters to the partition and CDROm-drives.
Create an account or sign in to comment