Created
November 17, 2012 23:12
-
-
Save ionelmc/4101243 to your computer and use it in GitHub Desktop.
windows-network-type-fixup.py
This file contains 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 win32com.client | |
NETWORK_CATEGORIES = { | |
1: "PRIVATE", | |
0: "PUBLIC", | |
2: "DOMAIN" | |
} | |
m = win32com.client.Dispatch("{DCB00C01-570F-4A9B-8D69-199FDBA5723B}") | |
more = 1 | |
pos = 1 | |
connections = m.GetNetworkConnections() | |
while more: | |
connection, more = connections.Next(pos) | |
if connection: | |
network = connection.GetNetwork() | |
category = network.GetCategory() | |
print '%s. "%s" is %s' % (pos, network.GetName(), NETWORK_CATEGORIES[category]) | |
if not category and raw_input("Make private [N]") in ['y', 'Y']: | |
network.SetCategory(1) | |
pos += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment