Reputation: 664
I am new to batch files and have seen several posts about findstr but could not get it to find a 169 inside a string which contains an IP address
set Foo=169.254.100.1
SET Foo|findstr /i 169
if ERRORLEVEL 1 (echo it doesnt contain 169, do launch) else (echo it contains 169, don't do launch)
)
Foo contains 169 as you can see, but when I do findstr, it returns 1 and shows "it doesnt contain 169, do launch"
Could anybody see what is wrong here?
Upvotes: 0
Views: 169
Reputation: 67226
May I suggest another way to achieve this test that does not use findstr?
set Foo=169.254.100.1
if "%Foo:169=%" equ "%Foo%" (
echo it doesnt contain 169, do launch
) else (
echo it contains 169, don't do launch
)
Upvotes: 1