Configure WINS NetBIOS parameters (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 enables the following three optional WINS parameters:
#  [1] Enable DNS as a backup for WINS name resolution
#  [2] Enable lookup from a central LMHOSTS file
#  [3] Configure the local computer with a NetBIOS Scope ID of "FINANCE"
# ------ SCRIPT CONFIGURATION ------

use Win32::OLE;

$strComputer = '.';
$EnableDNS = 1;
$EnableLMHosts = 1;
$LMHOSTSFile = '\\\\server1\\admin\\lmhosts';
$ScopeID = 'WORKGROUP';
# set this to the name of your NetBIOS Scope
# ------ END CONFIGURATION ---------

$objWMIService = Win32::OLE->GetObject('winmgmts:' . '{impersonationLevel=impersonate}!\\\\' . $strComputer . '\\root\\cimv2');

$nicConfig = $objWMIService->Get('Win32_NetworkAdapterConfiguration');

$EnableWINS = $nicConfig->EnableWINS($EnableDNS, $EnableLMHosts, $LMHOSTSFile, $ScopeID);
if ($EnableWINS == 0) {
    print "Set WINS options successfully!\n";
}
elsif ($intEnableWINS == 1) {
    print "Set WINS options successfully! Please reboot.\n";
}
else {
    print "Error! Unable to set WINS options.\n";
}

This code has been viewed 959 times.

New from the creators of TechTasks.com: StatSheet.com