Disable shutdown tracker (Perl)

This code can be found in Chapter 2 of Windows Server 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.

# This code disables the Shutdown Tracker from running.
# ---------------------------------------------------------------
# Adapted from VBScript code contained in the book:
#      "Windows Server Cookbook" by Robbie Allen
# ISBN: 0-596-00633-0
# ---------------------------------------------------------------
use Win32::OLE;
$Win32::OLE::Warn = 3;

# ------ SCRIPT CONFIGURATION ------
$intEnable = 0; # 0 = disable; 1 = enable screen
$strComputer = '.'; # e.g. rallen-srv01
# ------ END CONFIGURATION ---------
use constant HKLM => 0x80000002;
$strKeyPath = 'SOFTWARE\\Policies\\Microsoft\\Windows NT\\Reliability';
$objReg = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\default:StdRegProv');
$intRC1 = $objReg->CreateKey(HKLM, $strKeyPath);
$intRC2 = $objReg->SetDwordValue(HKLM, $strKeyPath, 'ShutdownReasonOn', $intEnable);
if ($intRC1 != 0 || $intRC2 != 0) {
    print 'Error setting registry value: ' . $intRC, "\n";
}
else {
    print "Successfully disabled shutdown tracker\n";
}

This code has been viewed 823 times.

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