Network config
Moderator: DosItHelp
Network config
Hi
I have 20 network card in my server.
I need a script the get over all the card and changed all the dhcp card to be disable.
i know that i doing it with netsh but how exactly?
Thanks in advance....
I have 20 network card in my server.
I need a script the get over all the card and changed all the dhcp card to be disable.
i know that i doing it with netsh but how exactly?
Thanks in advance....
Re: Network config
How will you set static IP addresses? Disabling dhcp is not the whole task, right?
Re: Network config
Yes I already set there all the Ip address
Now I need a script to disable of the nic's that are dhcp(dynamic ip).
Now I need a script to disable of the nic's that are dhcp(dynamic ip).
Re: Network config
I'm confused. Do you want to disable the NICs that are set to DHCP?
Re: Network config
Can you paste the output of this into a code block? I need to see what kind of output the command gives on your server.
Code: Select all
@echo off
ipconfig /all |findstr /i /c:"ethernet adapter " /c:"dhcp enabled"
pause
Re: Network config
This can detect if dhcp enabled or disabled, but after foxidrive asked for your output, i'm not sure if it will work for you too or not
you can then disable the NIC adapter with the command netsh

Code: Select all
@Echo OFF
Rem Detect if dhcp enabled or disabled
For /F "delims=" %%A In ('IPconfig /ALL ^|FINDstr /C:"Dhcp Enabled"') Do (
For /F "tokens=2 delims=:" %%B In ("%%A") Do (
IF "%%B" == " Yes" ( echo it's enabled
) Else ( echo disabled )
)
)
Pause
Re: Network config
Ethernet adapter LAN 04:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 03:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter 2:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 01:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 10:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 09:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 05:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 07:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 08:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 11:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 12:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 14:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 15:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 16:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 06:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 13:
DHCP Enabled. . . . . . . . . . . : Yes
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 03:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter 2:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 01:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 10:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 09:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 05:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 07:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 08:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 11:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 12:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 14:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 15:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 16:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 06:
DHCP Enabled. . . . . . . . . . . : Yes
Ethernet adapter LAN 13:
DHCP Enabled. . . . . . . . . . . : Yes
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
DHCP Enabled. . . . . . . . . . . : No
Re: Network config
Try this command and see what it outputs:
Code: Select all
wmic nicconfig where dhcpenabled='true' get description,index
Re: Network config
Description Index
Intel(R) PRO/1000 PT Dual Port Server Adapter 7
Intel(R) PRO/1000 PT Dual Port Server Adapter 11
Intel(R) PRO/1000 PT Dual Port Server Adapter 13
Intel(R) PRO/1000 PT Dual Port Server Adapter 15
Intel(R) PRO/1000 PT Dual Port Server Adapter 16
Intel(R) PRO/1000 PT Dual Port Server Adapter 18
Intel(R) PRO/1000 PT Dual Port Server Adapter 20
Intel(R) PRO/1000 PT Dual Port Server Adapter 23
Intel(R) PRO/1000 PT Dual Port Server Adapter 24
Intel(R) PRO/1000 PT Dual Port Server Adapter 26
Intel(R) PRO/1000 PT Dual Port Server Adapter 28
Intel(R) PRO/1000 PT Dual Port Server Adapter 30
Intel(R) I350 Gigabit Network Connection 33
Intel(R) I350 Gigabit Network Connection 34
Intel(R) Ethernet Controller X540-AT2 36
Intel(R) Ethernet Controller X540-AT2 38
Intel(R) PRO/1000 PT Dual Port Server Adapter 7
Intel(R) PRO/1000 PT Dual Port Server Adapter 11
Intel(R) PRO/1000 PT Dual Port Server Adapter 13
Intel(R) PRO/1000 PT Dual Port Server Adapter 15
Intel(R) PRO/1000 PT Dual Port Server Adapter 16
Intel(R) PRO/1000 PT Dual Port Server Adapter 18
Intel(R) PRO/1000 PT Dual Port Server Adapter 20
Intel(R) PRO/1000 PT Dual Port Server Adapter 23
Intel(R) PRO/1000 PT Dual Port Server Adapter 24
Intel(R) PRO/1000 PT Dual Port Server Adapter 26
Intel(R) PRO/1000 PT Dual Port Server Adapter 28
Intel(R) PRO/1000 PT Dual Port Server Adapter 30
Intel(R) I350 Gigabit Network Connection 33
Intel(R) I350 Gigabit Network Connection 34
Intel(R) Ethernet Controller X540-AT2 36
Intel(R) Ethernet Controller X540-AT2 38
Re: Network config
Then if all those adapters are NICs then this should work to disable them (untested):
In Windows 8 I get another adapter called "Microsoft Kernel Debug Network Adapter" and that's probably not a good thing to disable randomly, so the code would need to filter it out if it was used in Windows 8.
Code: Select all
@echo off
for /f "skip=1" %%a in ('wmic nicconfig where dhcpenabled^='true' get index') do (
wmic path win32_networkadapter where index=%%a call disable
)
pause
In Windows 8 I get another adapter called "Microsoft Kernel Debug Network Adapter" and that's probably not a good thing to disable randomly, so the code would need to filter it out if it was used in Windows 8.
Re: Network config
It doesn't work.
I got on the screen the message: true - invalid alias verb.
I got on the screen the message: true - invalid alias verb.
Re: Network config
Try it now - I escaped the = sign.
Re: Network config
No it's work bit in the end I got an error
Description=invalid query
Description=invalid query
Re: Network config
You can ignore that error. The WMIC output has embedded carriage returns and that entry has a blank carriage return.