-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetNetDrives.py
37 lines (29 loc) · 955 Bytes
/
getNetDrives.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import win32wnet
def printResource(resource, info = True, parent=True):
print '=' * 80
for elem in dir(resource):
if not elem.startswith('_'):
print getattr(resource, elem),
if info:
print
print
print 'info:'
resinfo, path = win32wnet.WNetGetResourceInformation(resource)
print 'path:', path
printResource(resinfo, info=False, parent=False)
print 'endinfo:'
if parent:
print
print 'parent:'
resinfo = win32wnet.WNetGetResourceParent(resource)
printResource(resinfo, info=False, parent=False)
print 'endinfo:'
print
print '=' * 80
def printAllNetworkDriveInfo():
handle = win32wnet.WNetOpenEnum(3, 1, 19, None)
resources = win32wnet.WNetEnumResource(handle)
for r in resources: print; printResource(r)
win32wnet.WNetCloseEnum(handle)
if __name__ == '__main__':
printAllNetworkDriveInfo()