Skip to content

Instantly share code, notes, and snippets.

@PatrickTerlisten
Created April 17, 2016 08:32
Show Gist options
  • Save PatrickTerlisten/859b71d6ccd925aa19ef4086172717dd to your computer and use it in GitHub Desktop.
Save PatrickTerlisten/859b71d6ccd925aa19ef4086172717dd to your computer and use it in GitHub Desktop.
Disable DHCPINFORM on Windows 2000, 2003, XP, Vista, 7
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT Name,DeviceID FROM Win32_NetworkAdapter WHERE NetConnectionStatus=2", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
strName = objItem.Name
Set colNicConfigs = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_NetworkAdapter.DeviceID='" & objItem.DeviceID & "'} WHERE AssocClass=Win32_NetworkAdapterSetting")
For Each objItemConfig In colNicConfigs
strSettingID = objItemConfig.SettingID
Next
Set wshShell = CreateObject( "WScript.Shell" )
wshShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & strSettingID & "\UseInform",0,"REG_DWORD"
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment