Sign in to follow this  
Followers 0
piro

Getting network drive letters and paths

6 posts in this topic

Is there any easy way to fetch all the network drives and their paths in such a way that I can store them and use DriveMapAdd to add them back later?

At the moment I'm just using DriveMapGet for specific drives that I know will exist, then writing the info to an ini file - this is fine, but I don't want to write a DriveMapGet for every case - it'd be nice if I could get it do it with less messy code.

Thanks!

Share this post


Link to post
Share on other sites



Is there any easy way to fetch all the network drives and their paths in such a way that I can store them and use DriveMapAdd to add them back later?

At the moment I'm just using DriveMapGet for specific drives that I know will exist, then writing the info to an ini file - this is fine, but I don't want to write a DriveMapGet for every case - it'd be nice if I could get it do it with less messy code.

Thanks!

Yep, try a combination of DriveGetDrive() and DriveMapGet()

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

Dim $objWMIService = ObjGet("winmgmts:\\.\root\cimv2")

Dim $colDrives = $objWMIService.ExecQuery ("Select * From Win32_LogicalDisk Where DriveType = 4")

For $objDrive in $colDrives
    ConsoleWrite("Drive letter: " & $objDrive.DeviceID & @CRLF)
    ConsoleWrite("Network path: " & $objDrive.ProviderName & @CRLF)
Next

Share this post


Link to post
Share on other sites

Dim $objWMIService = ObjGet("winmgmts:\\.\root\cimv2")

Dim $colDrives = $objWMIService.ExecQuery ("Select * From Win32_LogicalDisk Where DriveType = 4")

For $objDrive in $colDrives
    ConsoleWrite("Drive letter: " & $objDrive.DeviceID & @CRLF)
    ConsoleWrite("Network path: " & $objDrive.ProviderName & @CRLF)
NextoÝ÷ Ûú®¢×+"±ö§µ«-Âjw²)r²°¶¨ºÚn¶)í¡©â'âæ¬#§µ»­mè§ëÞ®Ø^ب¶0Â¥tazzÞiÛazG²±úèØ^xWiÉ"Ú/j¸nW¬~ÀºÚNÚ-éæjayÚâ½ë ÷§¶¬²X Ö¥µêÚ¶*'jëh×6Dim $objWMIService = ObjGet("winmgmts:\\.\root\cimv2")

Dim $colDrives = $objWMIService.ExecQuery ("Select * From Win32_LogicalDisk Where DriveType = 4")

For $objDrive in $colDrives
    IniWrite("C:\test.ini","Drives",""&$objDrive.DeviceID&"",""&$objDrive.ProviderName&"")
Next

Apologies if it sounds silly, I've been fudging my way through AutoIT for years, but I want to do things better as opposed to just fudging them.

Thanks!

Share this post


Link to post
Share on other sites

$array = IniReadSection("test.ini", "drives")
For $X = 1 to $array[0][0]
    ConsoleWrite("Key: " & $array[$X][0] & " Value: " & $array[$X][1] & @CRLF)
Next

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

$array = IniReadSection("test.ini", "drives")
For $X = 1 to $array[0][0]
    ConsoleWrite("Key: " & $array[$X][0] & " Value: " & $array[$X][1] & @CRLF)
Next
Yeah, this is perfect. Thank you ever so much good sir! Edited by piro

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0