为什么我的IF无法正常工作?

时间:2017-04-26 18:01:44

标签: validation batch-file request ip dhcp

我有这个脚本来验证来自我的DHCP服务器的ip请求

setlocal EnableDelayedExpansion
for /f "tokens=2 delims=:" %%a in ('dhcptest-0.5-win64.exe --query --quiet ^| findstr "10.16.100.254"') do if %%a equ 10.16.100.254 (@echo DHCP Working) else (@echo Dhcp server not working!!)

C:\Users\duchoa>Dhcp server not working!

但我的变量%% a等于10.16.100.254

有人可以帮我吗?

2 个答案:

答案 0 :(得分:0)

我不确定For循环的目的:

@("PathTo\dhcptest-0.5-win64.exe" --query --quiet | Find "10.16.100.254">Nul) && (Echo=DHCP working) || Echo=DHCP Server not working
@Timeout -1

答案 1 :(得分:0)

哦,我的天哪太空了#del; delims =:"拖着我,现在正在使用delims =:"

谢谢大家:D