Enable remote desktop (Perl)
This code can be found in
Chapter 17 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 enables/disables Remote Desktop on a computer.
# ------ SCRIPT CONFIGURATION ------
use Win32::OLE qw(in);
$strComputer = '.';
$boolEnable = 1;
# 1=enable; 0=disable
# ------ END CONFIGURATION ---------
$objWMI = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2');
$colItems = $objWMI->ExecQuery('Select * from Win32_TerminalServiceSetting');
foreach my $objItem (in $colItems) {
$intRC = $objItem->SetAllowTSConnections($boolEnable);
if ($intRC) {
print "Error enabling Remote Desktop\n";
}
else {
if ($boolEnable == 0) {
print "Remote Desktop disabled\n";
}
else {
print "Remote Desktop enabled\n";
}
}
}
|
This code has been viewed 1090 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|