JSI Tip 8271 How can I retrieve, or set, the NetBIOS over TCP/IP setting for an interface?

Jerold Schulman

July 19, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today


Using REG.EXE, built into Windows XP, Windows Server 2003, and later operating systems, or installed from the Windows 2000 Support Tools, and InterfaceGUID.bat, I have scripted EnableNBT.bat to retrieve or set the NetBIOS over TCP/IP setting for an interface.

The syntax for using EnableNBT.bat is:

EnableNBT Name Action Setting

Where:

Name    is the name of the Local Area Connection.Action  is an R to retrieve the NetBIOS over TCP/IP setting, or a W to write it.Setting is the name of a variable that will contain the NetbiosOptions if Action is an R or        if Action  is a W, the name of the variable that contains:                1 - NetBT is to be enabled on the interface, or               2 - NetBT is to be disabled on the interface.

EnableNBT.bat contains:

@echo offsetlocalif {%3}=={} goto errset Name=%1set Action=%2set NbtO=0xNset GUID=noneset key=HKLMSYSTEMCurrentControlSetServicesNetBTParametersInterfacesTcpipcall InterfaceGUID %Name% GUIDif "%GUID%" EQU "none" goto errset key="%key%_%GUID%"if /i "%Action%" EQU "R" goto Readif /i "%Action%" EQU "W" goto Write:err@echo Syntax EnableNBT Name Action Settingendlocalgoto :EOF:Readfor /f "Tokens=3" %%n in ('reg query %key% /v NetbiosOptions') do ( set NbtO=%%n)set NbtO=%NbtO:~2,1%endlocal&set %3=%NbtO%goto :EOF:Writecall set NbtO=%%%3%%call :quiet>nul 2>&1if ERRORLEVEL 0 goto finish@echo EnableNBT was unable to update NetbiosOptions - %key%:finishendlocalgoto :EOF:quietreg add %key% /v NetbiosOptions /t REG_DWORD /d %NbtO% /f



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like