Setup.py
from setuphelpers import *
import wmi
uninstallkey=[]
def install():
netcfg = wmi.WMI().win32_NetworkAdapterConfiguration
for connection in netcfg.query(IPEnabled = True):
if connection.TcpipNetbiosOptions != 2:
print(u'Disabling Netbios on %s' % connection.Description)
connection.SetTcpipNetbios(2)
def uninstall():
netcfg = wmi.WMI().win32_NetworkAdapterConfiguration
for connection in netcfg.query(IPEnabled = True):
if connection.TcpipNetbiosOptions == 2:
print(u'Enabling Netbios on %s' % connection.Description)
connection.SetTcpipNetbios(0)
def audit():
netcfg = wmi.WMI().win32_NetworkAdapterConfiguration
has_netbios = []
for connection in netcfg.query(IPEnabled = True):
if connection.TcpipNetbiosOptions != 2:
has_netbios.append(connection.Description)
if has_netbios:
print(u'ERROR: Netbios is not disabled on interfaces :\n%s'% u'\n'.join(has_netbios))
return 'ERROR'
else:
return 'OK'