現在のIP/サブネット/ゲートウェイ/DNSを取得して静的に設定するバッチファイルを作成しようとしています(XP以降)。すでに静的であっても、オンラインでスクリプトを見つけましたが、現在の IP 情報を見つける部分が必要です。アダプタの名前が常に「ローカル エリア接続」であれば問題ありませんが、そうではありません。誰でも助けることができますか?
@ECHO OFF
set varip=
set varsm=
set vargw=
set vardns1=
set vardns2=
set varhome=
ECHO Setting IP Address and Subnet Mask
netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm%
ECHO Setting Gateway
netsh int ip set address name = "Local Area Connection" gateway = %vargw% gwmetric = 1
ECHO Setting Primary DNS
netsh int ip set dns name = "Local Area Connection" source = static addr = %vardns1%
ECHO Setting Secondary DNS
netsh int ip add dns name = "Local Area Connection" addr = %vardns2%
rem ECHO Here are the new settings for %computername%:
rem netsh int ip show config
pause
ありがとう、
エリック