<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" > <channel> <title>ネットワーク | Qwerty.work</title> <atom:link href="https://qwerty.work/blog2/archives/category/%E3%83%8D%E3%83%83%E3%83%88%E3%83%AF%E3%83%BC%E3%82%AF/feed" rel="self" type="application/rss+xml" /> <link>https://qwerty.work/blog2</link> <description>パソコンに関することをいろいろメモしています。</description> <lastBuildDate>Fri, 09 Dec 2022 03:03:58 +0000</lastBuildDate> <language>ja</language> <sy:updatePeriod> hourly </sy:updatePeriod> <sy:updateFrequency> 1 </sy:updateFrequency> <generator>https://wordpress.org/?v=6.8.1</generator> <image> <url>https://qwerty.work/wp/wp-content/uploads/2022/11/cropped-favicon_QwertyWork-32x32.png</url> <title>ネットワーク | Qwerty.work</title> <link>https://qwerty.work/blog2</link> <width>32</width> <height>32</height> </image> <item> <title>[Windows]バッチファイルで固定IPとDHCPとプロキシ設定を入れ替える</title> <link>https://qwerty.work/blog2/archives/76</link> <dc:creator><![CDATA[postmaster]]></dc:creator> <pubDate>Fri, 09 Dec 2022 02:51:55 +0000</pubDate> <category><![CDATA[Windows]]></category> <category><![CDATA[ネットワーク]]></category> <category><![CDATA[バッチファイル]]></category> <guid isPermaLink="false">https://qwerty.work/blog2/?p=76</guid> <description><![CDATA[目次 ネットワーク設定を簡単に切り替えたいバッチファイルの内容 ネットワーク設定を簡単に切り替えたい パソコンの用途や使用するアプリケーションによって回線を切り替える必要のあるパソコンがあります。切り替えるたびにLANの […]]]></description> <content:encoded><![CDATA[ <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label> <div class="toc-content"> <ol class="toc-list open"><li><a href="#toc1" tabindex="0">ネットワーク設定を簡単に切り替えたい</a></li><li><a href="#toc2" tabindex="0">バッチファイルの内容</a></li></ol> </div> </div> <h2><span id="toc1">ネットワーク設定を簡単に切り替えたい</span></h2> <p>パソコンの用途や使用するアプリケーションによって回線を切り替える必要のあるパソコンがあります。切り替えるたびにLANの設定を変更するのが面倒になってきたので、バッチファイルで切替ることにしました。DHCPと固定IPの入れ替え及び、固定IPの場合はプロキシ接続の設定を有効化するようにしました。Windows 11/10で動作確認済みです。</p> <p><img fetchpriority="high" decoding="async" class="alignnone wp-image-82 size-full" src="https://qwerty.work/wp/wp-content/uploads/2022/12/ネットワーク切替bat.png" alt="ネットワーク切替bat" width="659" height="345" /></p> <h2><span id="toc2">バッチファイルの内容</span></h2> <p>メモ帳などのテキストエディタで拡張子を<code>.bat</code>にして保存してください。</p> <pre>@echo off rem /////////////////////////////////////////// rem rem DHCP と 固定IP&プロキシ設定を入れ替える rem バッチファイル rem rem /////////////////////////////////////////// :menu set NUM= set IFNAME="イーサネット 3" rem set IFNAME="ローカル エリア接続" CLS echo -------------------- MENU -------------------- echo [1] 現在のIPアドレスを表示 (ipconfig) echo [2] 固定IPとプロキシの設定を有効化 echo [3] DHCPとプロキシの設定を無効化 echo [4] インターネット(IE)のプロパティを開く echo [5] 終了 echo ---------------------------------------------- echo. set /p NUM="実行する処理の番号を入力 > " if "%NUM%"=="1" goto ipconfig if "%NUM%"=="2" goto addIpProxy if "%NUM%"=="3" goto dhcp if "%NUM%"=="4" goto inetcpl if "%NUM%"=="5" goto end goto NoNumber rem ------------------------------------------- :ipconfig ipconfig pause goto menu rem ------------------------------------------- :addIpProxy set IPADDR=192.168.1.100 set MASK=255.255.255.0 set GW=192.168.1.254 set DNS1=192.168.1.251 set DNS2=192.168.1.252 set PROXYIPaddr=192.168.1.250 set PORT=8080 rem set IntraAddr=*.hoge.local echo %IFNAME% に %IPADDR% を設定しています。 netsh interface ipv4 set address name=%IFNAME% static %IPADDR% %MASK% %GW% 1 netsh interface ipv4 set dnsservers name=%IFNAME% static %DNS1% primary validate=no netsh interface ipv4 add dnsservers name=%IFNAME% %DNS2% index=2 validate=no echo. echo 現在のユーザー %USERNAME% のプロキシ設定を有効化します。 reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /f /v ProxyEnable /t REG_DWORD /d 1 reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /f /v ProxyServer /t REG_SZ /d %PROXYIPaddr%:%PORT% rem reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /f /v ProxyOverride /t REG_SZ /d %IntraAddr% rem inetcpl.cpl ipconfig echo. echo 変更が完了しました。 pause goto menu rem ------------------------------------------- :dhcp echo %IFNAME% に DHCP を設定しています。 netsh interface ipv4 set address name=%IFNAME% dhcp netsh interface ipv4 set dnsservers name=%IFNAME% dhcp echo. echo プロキシ接続を無効化しています。 reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /f /v ProxyEnable /t REG_DWORD /d 0 rem inetcpl.cpl ipconfig echo. echo 変更が完了しました。 pause goto menu rem ------------------------------------------- :inetcpl inetcpl.cpl goto menu rem ------------------------------------------- :NoNumber echo メニューにない番号が入力されました。 echo. pause goto menu rem ------------------------------------------- :end exit</pre> ]]></content:encoded> </item> </channel> </rss>