Sam Kamran
Sam Kamran

Reputation: 33

Batch Script to get a IPV4 address of a computer then if the IP is within a range run a batch file

I'm trying to get this batch file to work. there are 2 ip ranges that need to be checked upon.

10.0.50.xxx 10.0.60.xxx

so far, I've done this with no avail.

[rolled back to original - OP has also experimented with * in the matching string]

     ipconfig | find /i "IPv4 Address. . . . . . . . . . . : 10.0.50." >nul 2>nul && (

  call script.bat 

) || (

  ipconfig | find /i "IPv4 Address. . . . . . . . . . . : 10.0.6." >nul 2>nul && (

  call script2.bat 

) || (

exit

any help would be much appreciated.

Upvotes: 0

Views: 418

Answers (1)

Compo
Compo

Reputation: 38604

Is this suitable?

IPConfig|FindStr/IRC:"IPv4 .*: 10.0.50.">Nul 2>&1 && (Call script.bat) || (
    IPConfig|FindStr/IRC:"IPv4 .*: 10.0.60.">Nul 2>&1 && Call script2.bat)

I'm afraid it is untested

Upvotes: 1

Related Questions