How to disable NETBIOS via command line on windows

If you want to disable a very old protocol on windows machines via command line, you can use WMIC (Microsoft Windows Management Instrumentation Command-line).

With this command you list all the network card:

wmic nicconfig get caption,index,TcpipNetbiosOptions

Output of command are something like this:
Identify the Index number of the NIC where you want to disable NETBIOS (for me is 8) and run the follow command with the correct index parameter:

wmic nicconfig where index=8 call SetTcpipNetbios 2

The SetTcpipNetbios parameter can have this value:

0 – Use NetBIOS setting from the DHCP server
1 – Enable NetBIOS over TCP/IP
2 – Disable NetBIOS over TCP/IP

You can also use a script for do that. The following script (vbs) disable NETBIOS on remote computers.

'Created by Luca Bazzuka
'for me stesso

On Error Resume Next
intArgIter = 0

If WScript.Arguments.Count = 0 Then
	WScript.Echo "NETConfig [\\Computer][Show|SetON|SetOFF]"
Else
	strComputerMAIN = "Non Inizializzata"
	Do While intArgIter <= WScript.Arguments.Count - 1
		strUserGivenArg = WScript.Arguments.Item(intArgIter)
		If LCase(Left(strUserGivenArg,2))="\\" Then
			strComputerMAIN = Mid(strUserGivenArg,3)
		End If
		intArgIter = intArgIter + 1
	Loop
	If strComputerMAIN = "Non Inizializzata" Then
		strComputerMAIN = "."
	End If
	intArgIter = 0
	Do While intArgIter <= WScript.Arguments.Count - 1
		strUserGivenArg = WScript.Arguments.Item(intArgIter)
		Select Case LCase(strUserGivenArg)
			Case LCase("SHOW")
				CALL SUBnetshow (strComputerMAIN)
			Case LCase("SETON")
				CALL SUBnetset (strComputerMAIN,0)
			Case LCase("SETOFF")
				CALL SUBnetset (strComputerMAIN,2)
		End Select
	intArgIter = intArgIter + 1
	Loop
End If
WSCript.Quit

Sub SUBnetshow (strComputer)

Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

For Each objNicConfig In colNicConfigs
  strDNSHostName = objNicConfig.DNSHostName
  intNetBIOS = objNicConfig.TcpipNetbiosOptions
  Select Case intNetBIOS
    Case 0 strNetBIOS = "Use NetBIOS setting from the DHCP server."
    Case 1 strNetBIOS = "Enable NetBIOS over TCP/IP."
    Case 2 strNetBIOS = "Disable NetBIOS over TCP/IP."
    Case Else strNetBIOS = "Unable to determine setting for NetBIOS " & _
     "Over TCP/IP."
  End Select
  strWINSSettings = strWINSSettings & VbCrLf & VbCrLf & _
   "  Network Adapter " & objNicConfig.Index & VbCrLf & _
   "    " & objNicConfig.Description & VbCrLf & VbCrLf & _
   "    NetBIOS: " & strNetBIOS & VbCrLf & _
   "    WINS Primary Server:             " & _
   objNicConfig.WINSPrimaryServer & VbCrLf & _
   "    WINS Secondary Server:           " & _
   objNicConfig.WINSSecondaryServer & VbCrLf & _
   "    WINS Scope ID:                   " & _
   objNicConfig.WINSScopeID & VbCrLf & _
   "    WINS Enable LMHosts Lookup:      " & _
   objNicConfig.WINSEnableLMHostsLookup & VbCrLf & _
   "    WINS Host Lookup File:           " & _
   objNicConfig.WINSHostLookupFile & VbCrLf & _
   "    DNS Enabled For WINS Resolution: " & _
   objNicConfig.DNSEnabledForWINSResolution
Next

WScript.Echo VbCrLf & "WINS Settings" & VbCrLf & VbCrLf & _
 "Host Name: " & strDNSHostName & strWINSSettings

End SUB

Sub SUBnetset (strComputer,strOpt)

Const ENABLE_NETBIOS_VIA_DHCP = 0
Const ENABLE_NETBIOS = 1
Const DISABLE_NETBIOS = 2

Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

WScript.Echo VbCrLf & "Host Name: " & strComputer
For Each objNicConfig in colNicConfigs
  WScript.Echo VbCrLf & "  Network Adapter " & objNicConfig.Index & _
   "    " & objNicConfig.Description & VbCrLf & _
  "    Attempting to set NetBIOS over TCP/IP."
  intNetBIOS = objNicConfig.SetTCPIPNetBIOS(strOpt)
  If intNetBIOS = 0 Then
    WScript.Echo "    Successfully set NetBIOS over TCP/IP"
  ElseIf intNetBIOS = 1 Then
    WScript.Echo "    Successfully set NetBIOS over TCP/IP" & _
     VbCrLf & "    Must reboot."
  Else
    WScript.Echo "    Unable to set NetBIOS."
  End If
Next

WScript.Echo VbCrLf & String(80, "-")

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

For Each objNicConfig In colNicConfigs
  WScript.Echo VbCrLf & _
   "  Network Adapter " & objNicConfig.Index & VbCrLf & _
   "    " & objNicConfig.Description
  intNetBIOS = objNicConfig.TcpipNetbiosOptions
  Select Case intNetBIOS
    Case 0 strNetBIOS = "Use NetBIOS setting from the DHCP server"
    Case 1 strNetBIOS = "Enable NetBIOS over TCP/IP"
    Case 2 strNetBIOS = "Disable NetBIOS over TCP/IP"
  End Select
  WScript.Echo "    NetBIOS Over TCP/IP: " & strNetBIOS
Next

End Sub

Script help:

NETConfig [\\Computer][Show|SetON|SetOFF]

[Computer] – The computer against you want to execute the script
[Show] – Display the current NETBIOS setting
[SetON] – Set NETBIOS on
[SetOFF] – Set NETBIOS off
Advertisements

10 thoughts on “How to disable NETBIOS via command line on windows

    • LS says:

      Copy script and paste it on notepad. Save the file as netconfig.vbs
      from command line (on path where you saved the script) type cscript netconfig.vbs \\mycomputer SetOff
      This disable netbios on mycomputer

  1. wrt says:

    you could use
    wmic nicconfig where TcpipNetbiosOptions=0 call SetTcpipNetbios 2
    then there’s no need to know the index – it simply disables NetBIOS at all indexes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s