计算机语言否定,计算机语言 DOS 批处理文件中的条件语句(if.....goto ),if后面是什么?它的否定形式是只需在if后加个not...

计算机语言 DOS 批处理文件中的条件语句(if.....goto ),if后面是什么?它的否定形式是只需在if后加个not

关注:138  答案:2  信息版本:手机版

解决时间 2019-01-04 12:28

佞臣

2019-01-04 08:12

计算机语言 DOS

批处理文件中的条件语句(if.....goto ),if后面是什么?它的否定形式是只需在if后加个not 吗?

最佳答案

轻雾山林

2019-01-04 09:40

是的

@Echo Off

Set n=1

If %n%==1 Echo 变量n等于1

If not %n%==1 Echo 变量n不等于1

If %n%==1 (Echo 变量n等于1) else (Echo 变量n不等于1)

Pause

也可以使用 else 条件为否的时候执行.

全部回答

1楼深街酒徒

2019-01-04 09:47

一:双向mac绑定 @echo off ::读取本机mac地址 if exist ipconfig.txt del ipconfig.txt ipconfig /all >ipconfig.txt if exist phyaddr.txt del phyaddr.txt find "physical address" ipconfig.txt >phyaddr.txt for /f "skip=2 tokens=12" %%m in (phyaddr.txt) do set mac=%%m ::读取本机ip地址 if exist ipaddr.txt del ipaddr.txt find "ip address" ipconfig.txt >ipaddr.txt for /f "skip=2 tokens=15" %%i in (ipaddr.txt) do set ip=%%i ::绑定本机ip地址和mac地址 arp -s %ip% %mac% ::读取网关地址 if exist gateip.txt del gateip.txt find "default gateway" ipconfig.txt >gateip.txt for /f "skip=2 tokens=13" %%g in (gateip.txt) do set gateip=%%g ::读取网关mac地址 if exist gatemac.txt del gatemac.txt arp -a %gateip% >gatemac.txt for /f "skip=3 tokens=2" %%h in (gatemac.txt) do set gatemac=%%h ::绑定网关mac和ip arp -s %gateip% %gatemac% arp -s 网关ip 网关mac exit 这个批处理要查询本机的arp 缓存表,看里面是不是有网关的ip和mac,有则能成功 绑定,但是没有的话就绑不定了!!!不过可以改进一下,达到双绑的目的,比如 加上arp -s 网关ip 网关mac一行就可以了。。。 二、这个也不能实现真正意义的双绑,只能绑定本机ip和mac (多谢中国dos联盟lxmxn提供) @echo off for /f "delims=: tokens=2" %%a in ('ipconfig /all^|find "physical address"') do set local_mac=%%a for /f "delims=: tokens=2" %%a in ('ipconfig /all^|find "ip address"') do set local_ip=%%a for /f "delims=: tokens=2" %%a in ('ipconfig /all^|find "default gateway"') do set gate_ip=%%a fo* /* %%* in ('getmac /nh /s %local_ip%') do set gate_mac=%%a arp -s %local_ip% %local_mac% arp -s %gate_ip% %gate_mac% (这个地方有问题,改进中……) 经测试,此批处理不能绑定网关ip和mac,只能绑定本机ip和mac 三、这个还不是很清楚,我要测试才行的,目前所知也能绑定本机ip和mac (多谢中国dos联盟everest79提供) @echo off setlocal enabledelayedexpansion for /f "tokens=2 delims=[]=" %%i in ('nbtstat -a %computername%') do call set local=!local!%%i for /f "tokens=3" %%i in ('netstat -r^|find " 0.0.0.0"') do set gm=%%i for /f "tokens=1,2" %%i in ('arp -a %gm%^|find /i /v "inter"') do set gate=%%i %%j arp -s %gate% arp -s %local% arp -s 网关ip 网关mac 这个批处理可以绑定网关ip和mac,但是还是有缺陷,要依赖于本机上存在的arp缓存! 改进方法为在最后加一个arp -s 网关ip和mac! 四、这个是一个兄弟的博客上找到的,原理和第一个一样,只是改进了一点点! 这个p通过ping网关三次得到了网关的mac其实以上的批都可以通过这个来搞定网关的ip和mac, 但是如果开机的时候正在发生arp欺骗的话这样你绑的ip和mac就是错的,不能上网了。。 不过这种情况很少,发过来试一下先吧! @echo off 清除所有的arp缓存 arp -d 读取本地连接配置 ipconfig /all>ipconfig.txt 读取内网网关的ip for /f "tokens=13" %%i in ('find "default gateway" ipconfig.txt') do set gatewayip=%%i ping三次内网网关 ping %gatewayip% -n 3 读取与网关arp缓存 arp -a|find "%gatewayip%">arp.txt 读取网关mac并绑定 for /f "tokens=1,2" %%i in ('find "%gatewayip%" arp.txt') do if %%i==%gatewayip% arp -s %%i %%j 读取本机的 ip+mac for /f "tokens=15" %%i in ('find "ip address" ipconfig.txt') do set ip=%%i for /f "tokens=12" %%i in ('find "physical address" ipconfig.txt') do set mac=%%i 绑定本机的 ip+mac arp -s %ip% %mac% 删除所有的临时文件 del ipconfig.txt del arp.txt exit 以上p可以配合路由上对客户机的ip和mac进行绑定实现完全防arp,只是单绑下面机和网关ip及mac

我要举报

如以上问答内容为色情/暴力/低俗/不良/侵权等信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!

大家都在看

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值