0

I have a Windows GPO that runs a batch file startup script to disable NetBIOS. It normally looks like this:

wmic nicconfig where (TcpipNetbiosOptions!=null and TcpipNetbiosOptions!=2) call SetTcpipNetbios 2

However, I just found out that I have one particular computer that needs NetBIOS enabled. I didn't want to make an entire new GPO for this one machine and I also wasn't sure if it would override the other one, which is global. Excuse my Pseudo-code, but How can I make it so this command will only execute if the computers IP is not a certain one?

IF(<This IP Address> != 192.168.1.1)
wmic nicconfig where (TcpipNetbiosOptions!=null and TcpipNetbiosOptions!=2) call SetTcpipNetbios 2

Or is there a better idea?

1

Would the computer's hostname be sufficient, instead of IP Address?

IF %COMPUTERNAME% NEQ NetBIOSPC (wmic nicconfig where (TcpipNetbiosOptions!=null and TcpipNetbiosOptions!=2) call SetTcpipNetbios 2)

Obviously, replace NetBIOSPC with the actual hostname of the system. Be sure you're using the right hostname by typing hostname or echo %COMPUTERNAME% at the local CMD prompt on the target system.

  • Cool, thanks. Would this work? IF NOT "%IP%"=="192.168.1.1" (wmic nicconfig where (TcpipNetbiosOptions!=null and TcpipNetbiosOptions!=2) call SetTcpipNetbios 2) – TheFrack Jul 10 '14 at 18:18
  • I wouldn't personally use IF NOT x == y where IF x NEQ y would be equally effective, but that's just a matter of personal preference. The only way you can use %IP% as an element in your conditional statement is if you have by some means already assigned the system's IP address to that variable - it is not a built-in environment variable, like %COMPUTERNAME% is. – Iszi Jul 10 '14 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.