Configure DHCP (Perl)
This code can be found in
Chapter 1 of Windows Server 2003 Networking Recipes
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 Server 2003 Networking Recipes"
# This code will configure the local computer
# to receive its IP configuration from DHCP
# ------ SCRIPT CONFIGURATION ------
use Win32::OLE qw(in);
$strComputer = '.';
# --------- END CONFIGURATION ------
$objWMIService = Win32::OLE->GetObject('winmgmts:' . '{impersonationLevel=impersonate}!\\\\' . $strComputer . '\\root\\cimv2');
$adapters = $objWMIService->ExecQuery('Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE');
foreach my $adapter (in $adapters) {
$errEnable = $adapter->EnableDHCP();
print "Successfully enabled DHCP on interface\n";
}
|
This code has been viewed 1062 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|