Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a simple script or batch method for checking the existence of a specific IP address (being moved between machines via NETSH) on the local network card. I need to start up certain services / apps etc ONLY if the specified IP address exists on the card.

Any ideas?


share|improve this question

powershell? save this as a .ps1 script and execute. (substitute the IP address you care about...)

$ipaddr = Get-WMIObject win32_NetworkAdapterConfiguration | Where-Object {$.IPEnabled -eq $true } | Foreach-Object { $.IPAddress } if ($ipaddr -eq "") { "Yes it's here" } else { "Nope" }

share|improve this answer
That's great, I'm finding Powershell extremely useful but have a long way to go in being able to come up with solutions like this. Thanks very much. – Codmental Jun 10 '11 at 7:43

Here's a batch script that uses ipconfig, parses the output for the ip address you specified. Then tells you if it was found or not.

To use it: paste the code into notepad saveas .bat file and execute it. Change the ip address to the one you want.

set ip=

ipconfig | find /i "%ip%" > nul
if %errorlevel% equ 0 (echo ip address found) else (echo ip address not found)
share|improve this answer
Nice and simple when you know how... thanks very much James - I will give that a try. – Codmental Jun 10 '11 at 7:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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