DOS批處理設定註冊表

來源:互聯網
上載者:User
最近因為設定代理的原因,總是需要開啟和關閉IE的proxy,都設定煩了,所以寫了個小工具,前提是註冊表裡面已經有了proxy代理的伺服器設定,只是PorxyEnable項沒有開啟,這樣,我們根據當前ProxyEnable的值來設定Proxy的開啟和關閉,相當於操作了IE瀏覽器的 工具->Internet選項->串連(connection)->區域網路設定(Lan Setting)中,將 使用proxy作為Lan的代理項給勾了....
關注點:
(1)批處理擷取命令的輸出為批處理中某個變數
(2)for,if,reg命令使用
代碼:

  1. @echo off
  2. @Set DefaultV=1
  3. for /F "delims=/ " %%n in ('@reg query "HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Internet Settings" /v ProxyEnable ') do @set Var=%%n%
  4. @Set Var2=%Var:~24,1%
  5. if %Var2% == 1 echo Proxy ON, Set OFF! && @Set DefaultV=0
  6. if not %Var2% == 1 echo Proxy OFF, Set ON! && @Set DefaultV=1
  7. @reg add "HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Internet Settings" /v ProxyEnable /t REG_DWORD /d %DefaultV% /f
  8. echo ProxyEnable Set to: %DefaultV% ! 
  9. pause

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.