On Thu, Jan 30, 2014 at 8:13 AM, danz <ze...@yahoo.com> wrote: > I apologize to all, but my above code won't work with paths that have > embedded spaces. It also turns out that the "net use" command inserts a > carriage-return/line-feed between the Path and Network fields when the last > character position of the Path exceeds 80 characters. > > My above approach seemed simpler, but that's just because I posted it > before adequate testing. Unfortunately, in order to make it actually work > for all cases, the implementation becomes more complex and begins to look > like a kludge. So my recommendation is to use Tim's ctypes approach.
You could use WMI's Win32_LogicalDisk class [1]. One way is to parse CSV output from wmic.exe [2]: wmic LogicalDisk WHERE "DriveType=4" ^ GET DeviceID, ProviderName /format:csv You can parse the output using the csv module. Or use Tim's wmi module [3]: import wmi DRIVE_REMOTE = 4 def available_network_drives(): net_drives = dict() c = wmi.WMI() for drive in c.Win32_LogicalDisk(DriveType=DRIVE_REMOTE): net_drives[drive.DeviceID] = drive.ProviderName return net_drives [1] http://msdn.microsoft.com/en-us/library/aa394173 [2] http://ss64.com/nt/wmic.html [3] http://timgolden.me.uk/python/wmi/index.html _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor