Skip to content

Instantly share code, notes, and snippets.

@ionelmc
Created November 17, 2012 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ionelmc/4101243 to your computer and use it in GitHub Desktop.
Save ionelmc/4101243 to your computer and use it in GitHub Desktop.
windows-network-type-fixup.py
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