Advertisement
Guest User

Untitled

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