Enable/disable NetBIOS over TCP/IP

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search

When you don't have any Windows NT machines in your network (any more) and only XP or higher; You can safely disable NetBIOS over TCP/IP so there is a bit less network traffic. Also when you are using *nix SAMBA servers; by disabling this setting on the clients, you won't see the constant error-logging "connection reset by peer" and "error writing x bytes to client" whenever an XP client connects to the SAMBA share.

A package that can be used for this task:

<package id="setNetBIOSoverTCPIP"
         name="Set NetBIOS over TCP/IP setting"

    <install cmd='%comspec% /c cscript "%SOFTWARE%\WindowsSettings\setNetBIOSoverTCPIP.vbs" /Nologo' />
    <upgrade cmd='%comspec% /c cscript "%SOFTWARE%\WindowsSettings\setNetBIOSoverTCPIP.vbs" /Nologo' />

Note: there is no remove command; you could consider setting the setting to "DEFAULT" (see below) as a removal command. Or if someone finds a method to 'remember' the old setting, before this package is installed, so it can be set back during removal?

The actual vbscript to perform the setting on all active network interfaces: setNetBIOSoverTCPIP.vbs

' This code sets the NetBIOS over TCP/IP setting

strComputer = "."

Const DEFAULT = 0
Const ENABLED = 1
Const DISABLED = 2
' ------ END CONFIGURATION ---------

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 

Set nics = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

For Each nic In nics

Note: You can set SetTCPIPNetBIOS to ENABLED to enable the setting, or to DEFAULT if you want Windows to rely on what a DHCP server tells him.
Note2: absolutely no error-checking is done in this script. Check the returnvalue saved in intNetBT for any error-values if you want.
Note3: I have seen this script fail when there are a few Dail-Up connections defined in Windows XP. Not sure what went wrong there.