[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1102
  • Last Modified:

netsh

As of now I am doing this on the login script

netsh interface ip set dns name="Local Area Connection" source=dhcp
netsh interface ip set wins name="Local Area Connection" source=dhcp
netsh interface ip set dns name="Local Area Connection 1" source=dhcp
netsh interface ip set wins name="Local Area Connection 1" source=dhcp
netsh interface ip set dns name="Local Area Connection 2" source=dhcp
netsh interface ip set wins name="Local Area Connection 2" source=dhcp
netsh interface ip set dns name="Local Area Connection 3" source=dhcp
netsh interface ip set wins name="Local Area Connection 3" source=dhcp
netsh interface ip set dns name="Local Area Connection 4" source=dhcp
netsh interface ip set wins name="Local Area Connection 4" source=dhcp

Is there a way to do?
netsh interface ip set dns name="*.*" source=dhcp
netsh interface ip set wins name="*.*" source=dhcp
0
alisafia
Asked:
alisafia
1 Solution
 
MSE-dwellsCommented:
I'm not familar with a netsh natural way of 'wildcarding' the interface names although that's certainly not to say it isn't there.  In the meantime, the following will do as you ask, simply copy and paste it into a .cmd file and execute.  I tested it against XP and Vista.  Note that I placed an 'echo' statement in front on the netsh syntax, remove the 'echo' when you're comfortable with its results -

@echo off

setlocal ENABLEDELAYEDEXPANSION

for /f "tokens=*" %%i in ('netsh interface show interface ^| findstr /b "Enabled"') do (
      set STRING=%%i
      set STRING=!STRING:~47!
      if not "!STRING!"=="Internal" (
            if not "!STRING!"=="Loopback" (
                  echo netsh interface ip set dns name="!STRING!" source=dhcp
                  echo netsh interface ip set wins name="!STRING!" source=dhcp
            )
      )
)
0
 
alisafiaAuthor Commented:
cool thanks man.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now