Enable dead gateway detection (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 dead gateway detection for all configured network adapters.
# ------ SCRIPT CONFIGURATION ------

use Win32::OLE;

$strComputer = '.';
$boolEnable = 1;
# set to FALSE to disable
# ------ END CONFIGURATION ---------
$objWMIService = Win32::OLE->GetObject('winmgmts:' . '{impersonationLevel=impersonate}!\\\\' . $strComputer . '\\root\\cimv2');

$objSettings = $objWMIService->Get('Win32_NetworkAdapterConfiguration');
$objSettings->SetDeadGWDetect($boolEnable);

print "Dead gateway detection set to $boolEnable\n";

This code has been viewed 817 times.

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