I have a piece of code that works correctly if the data DefaultIPGateway is available. If the data isn't available, it produces the message "No Instance(s) Available.".
Code: Select all
For /f "tokens=2,3 delims={,}" %%a In ('"WMIC NICConfig Where IPEnabled="True" Get DefaultIPGateway /Value | Find "I" "') Do ^
echo Default IP Gateway : %%~a >> "%OUTPUT%"
I have tried the following which does output Default IP Gateway:, but still outputs the "No Instance(s) Available." which I want the message suppressed so it doesn't ouput on the cmd screen.
Code: Select all
For /f "tokens=2,3 delims={,}" %%a In ('"WMIC NICConfig Where IPEnabled="True" Get DefaultIPGateway /Value | Find "I" "') Do Set %_DefaultIPGateway%
echo Default IP Gateway :%_DefaultIPGateway%
echo Default IP Gateway :%_DefaultIPGateway% >> "%OUTPUT%"
Code: Select all
For /f "tokens=2,3 delims={,}" %%a In ('"WMIC NICConfig Where IPEnabled="True" Get DefaultIPGateway /Value | Find "I" "') Do Set _DefaultIPGateway=%%a
echo Default IP Gateway :%_DefaultIPGateway%
echo Default IP Gateway :%_DefaultIPGateway% >> "%OUTPUT%"