设为首页 加入收藏

TOP

阿里云添加路由的Windows批处理文件
2017-10-11 17:22:44 】 浏览:851
Tags:阿里 添加 路由 Windows 处理 文件

一段很好的学习bat程序的示例代码,如下:

@echo off

route print -4 "10.0.0.0" | find "10.0.0.0" > route_list
set gw=

for /F "tokens=1-5" %%a in ('type route_list') do (
 if not "%%c" == "" ( set gw=%%c )
)

if "%gw%" == "" ( echo "fail to get eth0 default gw" && goto error)


route print -4 100.64.0.0 | find "%gw%" > NUL
if not "%errorlevel%" == "0" (
    route -p add 100.64.0.0 mask 255.192.0.0 %gw% > NUL 2>&1
)
if not "%errorlevel%" == "0" ( echo "faild to add route 100.64.0.0/10" && goto error)

:success
del route_list
echo "add 100.64.0.0/10 success !"
timeout 10
exit 0

:error
timeout 10
exit 1

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Windows使用总结 下一篇DOS下windows系统查看wifi密码

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目