Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: Set primary and alternate DNS for IPv4 on Windows Server 2000/2003/2008 & Windows XP/Vista/7
- @ECHO OFF
- SETLOCAL EnableDelayedExpansion
- SET adapterName=
- FOR /F "tokens=* delims=:" %%a IN ('IPCONFIG ^| FIND /I "ETHERNET ADAPTER"') DO (
- SET adapterName=%%a
- REM Removes "Ethernet adapter" from the front of the adapter name
- SET adapterName=!adapterName:~17!
- REM WinXP Remove some weird trailing chars (dunno what they are)
- FOR /l %%a IN (1,1,255) DO IF NOT "!adapterName:~-1!"==":" SET adapterName=!adapterName:~0,-1!
- REM Removes the colon from the end of the adapter name
- SET adapterName=!adapterName:~0,-1!
- echo !adapterName!
- GOTO:EOF
- netsh interface ip set dns name="!adapterName!" static x.x.x.x primary
- netsh interface ip add dns name="!adapterName!" x.x.x.x index=2
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement