Reputation: 3
I want to create a Windows Batch script (.bat) file. First of all I need to check the computer IP address and when its in a predefinied range like 172.18.. then the script will run toward else the script will go to exit. Please let me know how to made it in the easy way. Thank you.
Upvotes: 0
Views: 1839
Reputation: 7095
This should get you started.
@echo off
setlocal
for /f "tokens=2 delims=:" %%a in ('ipconfig^|find "IP Address"') do (
for /f "tokens=1,2 delims=." %%b in ('echo %%a') do (
if "%%b.%%c"==" 172.18" (echo do stuff) else echo no match. exiting&exit /b 1
)
)
Upvotes: 1