» 您尚未登录:请 登录 | 注册 | 标签 | 帮助 | 小黑屋 |


发新话题
打印

[电脑] 用脚本切换IP

@echo off
    set ProxyServerValue=fetfw.fareastone.com.tw:8080
    set ProxyOverrideValue="10.*,<local>"  
    set NetConf="local"
    set TestIP="10.68.68.254"

    if "%1%"=="work" goto work
    if "%1%"=="home" goto home
    if "%1%"=="dhcp" goto dhcp
    if "%1%"=="p" goto proxy
    if "%1%"=="np" goto noproxy
    if "%1%"=="t" goto test
    echo 命令有误,按任意退出。
    pause >nul
    exit

:work
    set MyIP=192.168.254.31
    set MyGateWay=192.168.254.254
    set MyMask=255.255.255.0      
    set DNS1=168.95.1.1
    set DNS2= 61.57.168.11
    goto setip

:home
    set MyIP=192.168.254.31
    set MyGateWay=192.168.254.254
    set MyMask=255.255.255.0      
    set DNS1=168.95.1.1
    set DNS2= 61.57.168.11
    goto setip

:dhcp
    netsh interface ip set address "%NetConf%" dhcp
    netsh interface ip set dns "%NetConf%" dhcp
    exit

:setip
    netsh interface ip set address name="%NetConf%" source=static addr=%MyIP% mask=%MyMask%
    netsh interface ip set address name="%NetConf%" gateway=%MyGateWay% gwmetric=0
    netsh interface ip set dns name="%NetConf%" source=static addr=%DNS1% register=PRIMARY
    netsh interface ip add dns name="%NetConf%" addr=%DNS2%
    netsh interface ip set wins name="%NetConf%" source=static addr=none
    exit
   
:proxy
    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 00000001 /f
    exit

:noproxy
    reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t reg_dword /d 00000000 /f
    exit

:test
    ping %TestIP%
    pause
    exit


另存为 ip.bat ,把自己的ip替换 work或home,ProxyServerValue是代理服务器,运行 ip work/home/dhcp 就可以切换ip了


TOP

没想到还有和我一样无聊的人,不过我是用ERRORLEVEL自动判断



TOP

这怎么无聊啊,挺好用的阿,比一些破软件好多了


TOP

说说是干嘛用的

TOP

引用:
原帖由 ryuetsuya 于 2007-8-15 17:02 发表
说说是干嘛用的
换ip用的,你要是经常带笔记本几个地方跑,每跑个地方不是要切换ip吗,用这个方便,虽然有软件干这个,但脚本自己随便改体积小啊:D

TOP

发新话题
     
官方公众号及微博