- セットアップスクリプトを利用する環境
- プロキシサーバを利用する環境
- プロキシを利用しない環境
を行き来する必要があったので、切り替えるバッチファイルを作りました。
今回、バッチファイル作成にあたりGithub Copilotを利用しました。やりたいことをコメントに書くと、スー...っと、こんな感じ?、とコードが提案されるのに驚き、また、ほぼやりたいことを記述してくれることにも驚きました。
提案されるコードの評価は必要ですが、いままでよりずっと早くやりたいことを書きあげられるのは新体験でした。現在無料試用期間ですが、これは課金決定ですね。Copilot Xも楽しみです。
検証環境
Windows 11 Home 22H2
コード
管理者として実行すること。
@echo off set /p choice=設定を選択 (1:セットアップスクリプトを使う, 2:プロキシサーバを使う, 3:プロキシ設定をクリアする): set pac=http://hoge.com/proxy.pac set proxy=proxy.hoge.com set port=8080 set exception=*.hoge.com;*.fuga.com if %choice%==1 ( echo セットアップスクリプトを利用します reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /t REG_SZ /d "%pac%" /f ) else if %choice%==2 ( echo プロキシサーバを利用します reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d "%proxy%:%port%" /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "%exception%" /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f ) else if %choice%==3 ( echo プロキシ設定をクリアします reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /f reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /f reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f ) else ( echo 1,2,3のいずれかを入力してください。 ) pause