DHCP_enable.vbs


script to enable a DHCP client, i.e. set the network configuration of a PC to : "use DHCP"

This script could be part of an autamatic installation : post-configuration tasks. Unfortunately, it does not work for Windows 98.


'Script : Microsoft Portable Script Center

	strComputer = "."
	Set objWMIService = GetObject("winmgmts:" _
    				& "{impersonationLevel=impersonate}!\\" _ 
				& strComputer & "\root\cimv2")

	Set colNetAdapters = objWMIService.ExecQuery _
    		("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
 
	For Each objNetAdapter In colNetAdapters
    		errEnable = objNetAdapter.EnableDHCP()
	Next

	Wscript.Echo "errorlevel :  " & errEnable
	Set colNetAdapters = Nothing
	Set objWMIService = Nothing



		

Koen Noens
june 7, 2005