Disable local admin (Perl)

This code can be found in Chapter 2 of Windows Server 2003 Security 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 local administrator account.
# ------ SCRIPT CONFIGURATION ------

use Win32::OLE;

$strComputer = '.';
$strAdminName = '<NewAdminName>';
# e.g. mike
# ------ END CONFIGURATION ---------

$objComputer = Win32::OLE->GetObject('WinNT://' . $strComputer);
$objUser = Win32::OLE->GetObject('WinNT://' . $strComputer . '/' . $strAdminName . ',user');
$objUser->{AccountDisabled} = 1;
$objUser->SetInfo();
print "Successfully disabled account: $strAdminName\n";

This code has been viewed 921 times.

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