設定IP和代理的Windows Bat指令碼

來源:互聯網
上載者:User

從什麼地方抄來的已經記不清了,為了防止丟失,做個備份。

 1 @echo off
2 cls
3 color 0A
4 Echo The program is running...
5 Echo Setting the ip and dns...
6 netsh interface ip set address name="Local Connection" source=dhcp
7 netsh interface ip delete dns "Local Connection" all
8 ipconfig /flushdns
9 ipconfig /all
10 Echo Done.
11 Echo Setting the proxy
12 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
13 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "proxy:80" /f
14 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "" /f
15 ipconfig /flushdns
16 Echo Done.
17 Echo Press any key to leave...
18 Pause

 這段代碼第一部分設定ip地址為自動擷取,然後設定Proxy 伺服器為“porxy:80”;

 1 @echo off
2 cls
3 Echo The program is running...
4 Echo Setting the ip and dns...
5 cmd /c netsh interface ip set address name="Local Connection" source=static addr=192.168.2.12 mask=255.255.255.0 gateway=192.168.2.1 gwmetric=1
6 cmd /c netsh interface ip set dns name="Local Connection" source=static addr=192.168.2.254 primary
7 cmd /c netsh interface ip add dns name="Local Connection" addr=192.168.2.253 index=2
8 ipconfig /all
9 Echo Done
10
11 Echo Setting the proxy...
12 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
13 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "" /f
14 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d 0 /f
15 Echo Done.
16 Pause

這段代碼設定了固定的IP地址和DNS等配置資訊,同時刪除了代理設定資訊(文中的IP地址都是我捏造的,需要根據實際情況填寫)。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.