文档详情

分享一些BAT批处理代码.doc

发布:2017-12-09约5.2千字共8页下载文档
文本预览下载声明
分享几个简单的BAT批处理代码 /share-a-few-simple-bat-batch-code.html 在前面的文章中我提到过BAT批处理,有时BAT除了进行程序处理,还能帮助我们简单的实现一些小的功能,对我这样的很懒的人是很有用处的。比如我懒得去手动修改IP地址,懒得手动修改IE的代理设置,我可以使用BAT简单一键搞定。再比如我刚装的系统,没有网络不能使用360安全卫士去下载补丁,但我手里有一堆补丁文件,我可以使用BAT批量安装它们,省的一个个安装,所以说BAT有时会帮助我们处理一些繁琐的小问题,让我们更加省心的去干别的事情。 在这里我分享一下自己使用的几个BAT小代码,也算一个小收藏。有的都是老掉牙的东西,大伙们别鄙视我呀。以下的代码拷贝下保存为XX.bat即可。 PS:不是什么高深东西,就是图个方便。 NO.1 使用批处理修改IP地址 修改成指定的IP地址:将以下“您的XX”替换为实际的内容。 @echo off echo This is the begin.. echo 设置本地连接的ip地址为:您的IP地址,子网掩码为:您的子网掩码 netsh interface ip set address name=本地连接 source=static addr=IP地址 mask=子网掩码 echo 设置网关为您的网关 netsh interface ip set address name=本地连接 gateway=您的网关 gwmetric=0 echo 设置主DNS为您的DNS netsh interface ip set dns name=本地连接 source=static addr=您的DNS register=PRIMARY echo 设置备份DNS为您的备份DNS netsh interface ip add dns name=本地连接 addr=您的备份DNS index=2 echo 设置wins netsh interface ip set wins name=本地连接 source=static addr=none echo This is the ending.. 修改成自动获取IP地址: @echo off echo This is the begin.. netsh interface ip set address name=本地连接 source=dhcp netsh interface ip set dns name=本地连接 source=dhcp register=PRIMARY netsh interface ip set wins name=本地连接 source=dhcp echo This is the ending.. No.2 使用批处理修改IE的代理设置:(修改注册表) 设置成使用代理,将以下“IP:端口”修改成实际内容 echo off echo 开始设置IE代理 @REM 代理服务器IP和端口(类似:11:8080) set ProxyServerValue=IP:端口 @REM 不使用代理服务器的网络,若有多个地址,用逗号隔开 set ProxyOverrideValue=local @REM 启用IE代理服务器 echo echo 正在设置IE代理服务器信息... reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings /v ProxyServer /t reg_sz /d %ProxyServerValue% /f reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings /v ProxyOverride /t reg_sz /d %ProxyOverrideValue% /f reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings /v ProxyEnable /t reg_dword /d/f echo. echo 设置完成 ^0^ pause 设置成不使用代理。 echo off echo 开始取消IE代理 echo 取消IE代理服务器... reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings /v ProxyEnable /t reg_dword /d/f
显示全部
相似文档