1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Windowsバッチファイルでネットワーク設定を変更したい件

Posted at

はじめに

在宅勤務でノートPCを会社から持ち出す時にネットワーク設定を一々切り替えるのが面倒!と言うときにはWindowsバッチファイルを使います。

IPアドレスの設定

以下の内容を丸っと書いて xxx.bat にて保存。

netsh interface ipv4 set address name="イーサネット" source=static address="xxx.xxx.xxx.xxx" mask="255.255.255.0" gateway="xxx.xxx.xxx.1"

DNSの設定

プライマリ、セカンダリを設定します。

netsh interface ipv4 set dns name="イーサネット" source=static address="aaa.aaa.aaa.aaa" register=primary validate=no
netsh interface ipv4 add dns name="イーサネット" address="bbb.bbb.bbb.bbb" index=2 validate=no

pacファイルの設定

利用するプロキシが書かれているpacファイルを読み込むには、レジストリを操作する必要があるようです。

REM pacファイルを使うとき
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v "AutoConfigURL" /t REG_SZ /d "http://www.XXX.ne.jp/proxy.pac" /f

REM pacファイルを使わないとき(ダイレクトアクセス)
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v "AutoConfigURL" /t REG_SZ /f

おまけ

Windows10でbatファイルを開こうとすると警告画面のようなものが表示されてびっくりした。

(おわり)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?