10.4. Renewing or Releasing a DHCP IP Address
You want to release or renew an IP address obtained via DHCP.
Using a graphical user interface
From the Control Panel, open the Network Connections applet.
Right-click the DHCP-enabled network connection you want to renew and select Repair. This will automatically attempt to renew the connection's IP address.
Using a command-line interface
The following commands renew and release a DHCP IP address, respectively:
> ipconfig /renew > ipconfig /release
With either of these commands, you can specify a pattern to match if you want to affect only a subset of adapters. The following command would release the IP address for any adapter that had "Con" (e.g., Local Area Connection 1) in its name:
> ipconfig /renew *Con*
' This code releases all DHCP IP addresses. ' ------ SCRIPT CONFIGURATION ------ strComputer = "." ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set objAdapterConfig = objWMI.Get("Win32_NetworkAdapterConfiguration") intRC = objAdapterConfig.ReleaseDHCPLeaseAll( ) if intRC = 0 then WScript.Echo "Released all DHCP IP addresses" elseif intRC = 1 then WScript.Echo "You must reboot to release all DHCP IP addresses" else WScript.Echo "There was an error releasing all DHCP IP addresses: " & intRC end if ' This code shows performs the same function as the previous example ' but it performs a query for all DHCP enabled IP addresses. Use this ' if you don't ...