Release all DHCP IP addresses (Perl)
This code can be found in
Chapter 12 of Windows XP Cookbook
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Perl code from this site.
# From the book "Windows XP Cookbook"
# ISBN: 0596007256
# ------ SCRIPT CONFIGURATION ------
use Win32::OLE;
$strComputer = '.';
# ------ END CONFIGURATION ---------
$objWMI = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2');
$objAdapterConfig = $objWMI->Get('Win32_NetworkAdapterConfiguration');
$intRC = $objAdapterConfig->ReleaseDHCPLeaseAll();
if ($intRC == 0) {
print "Released all DHCP IP addresses\n";
}
elsif ($intRC == 1) {
print "You must reboot to release all DHCP IP addresses\n";
}
else {
print 'There was an error releasing all DHCP IP addresses: ' . $intRC, "\n";
}
|
This code has been viewed 987 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|