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?

TheFrack
  • 289
  • 5
  • 7
  • 21
  • possible duplicate of [How to get LAN ip to a variable in a Windows batch file](http://superuser.com/questions/230233/how-to-get-lan-ip-to-a-variable-in-a-windows-batch-file) + `IF NOT "%IP%"=="192.168.1.1"`. – Ƭᴇcʜιᴇ007 Jul 07 '14 at 20:38

1 Answers1

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.

Iszi
  • 13,585
  • 44
  • 113
  • 181
  • 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