Doc Symbiosis Posted November 12, 2005 Posted November 12, 2005 (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 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, 2005 by Doc Symbiosis
gunsmokingman Posted November 12, 2005 Posted November 12, 2005 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")
gosherm Posted November 12, 2005 Posted November 12, 2005 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.
Doc Symbiosis Posted November 12, 2005 Author Posted November 12, 2005 I want automatically assign drive letters to the partition and CDROm-drives.
gosherm Posted November 12, 2005 Posted November 12, 2005 Check out the thread about MapDrive. It's what I'm using and it works great.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now