Created
April 14, 2015 20:15
-
-
Save SteveGilham/960c0ec46c88f22d02fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import clr | |
| clr.AddReference("System.Management") | |
| import System | |
| from System.Management import * | |
| logicalDrives = None | |
| def getLogicalDrives(): | |
| global logicalDrives | |
| if None == logicalDrives: | |
| DiskSearch = ManagementObjectSearcher(SelectQuery("Select * from Win32_LogicalDisk")) | |
| try: | |
| moDiskCollection = DiskSearch.Get() | |
| logicalDrives = [] | |
| try: | |
| for mo in moDiskCollection: | |
| logicalDrives.append(mo["Name"]) | |
| mo.Dispose() | |
| finally: | |
| moDiskCollection.Dispose() | |
| finally: | |
| DiskSearch.Dispose() | |
| return logicalDrives | |
| if __name__ == "__main__": | |
| print getLogicalDrives() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment