Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

Thanks.

share|improve this question
add comment

2 Answers

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 "10.10.10.10") { "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
add comment

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=192.168.1.1

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
add comment

Your Answer

 
discard

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.