[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 # Script to configure Remote Desktop (aka. Terminal Services). 2 3 use warnings; 4 use strict; 5 use Getopt::Long; 6 use Pod::Usage; 7 use Win32::OLE; 8 9 # Your usual option-processing sludge. 10 my %opts; 11 GetOptions (\%opts, 'help|h|?', 'remote=s', 'allow=i') 12 or pod2usage (2); 13 14 (exists $opts{'help'}) 15 and pod2usage ('-exitstatus' => 0, '-verbose' => 2); 16 17 # Ensure no arguments after options. 18 scalar @ARGV == 0 19 or pod2usage (2); 20 21 (defined $opts{'allow'}) 22 or pod2usage (2); 23 24 # Bomb out completely if COM engine encounters any trouble. 25 Win32::OLE->Option ('Warn' => 3); 26 27 # Get a handle to the SWbemServices object of the machine. 28 my $computer = Win32::OLE->GetObject (exists $opts{'remote'} 29 ? "WinMgmts://$opts{'remote'}/" 30 : 'WinMgmts:'); 31 32 # Get the Win32_TerminalServiceSetting objects for the machine. There 33 # should be only one. See 34 # <http://msdn.microsoft.com/library/en-us/termserv/termserv/win32_terminalservicesetting.asp> 35 my $ts_set = $computer->InstancesOf ('Win32_TerminalServiceSetting'); 36 37 # Convert set to Perl array. 38 my @ts = Win32::OLE::Enum->All ($ts_set); 39 40 if (scalar @ts < 1) { 41 print "$0: Win32_TerminalServiceSetting class not found; nothing to do.\n"; 42 exit 0; 43 } 44 45 scalar @ts == 1 46 or die "Internal error"; 47 48 my $ts = $ts[0]; 49 50 my $ret = $ts->SetAllowTSConnections($opts{'allow'}); 51 $ret == 0 52 or die "SetAllowTSConnections failed: %d\n"; 53 54 exit 0; 55 56 =head1 NAME 57 58 rdconfig.pl - Configure Remote Desktop (aka. Terminal Services) 59 60 =head1 SYNOPSIS 61 62 rdconfig.pl [ options ] 63 64 Options (may be abbreviated): 65 66 --help Display verbose help and exit 67 --remote=<host> Operate on <host> instead of local machine 68 --allow=<arg> Allow/disallow remote connections 69 70 =head1 DESCRIPTION 71 72 This script configures the Remote Desktop for Windows XP and above. 73 74 Use --allow=1 to enable Remote Desktop connections and --allow=0 to 75 disable them. 76 77 =head1 NOTES 78 79 To change the list of users who can access the machine remotely, edit 80 the "Remote Desktop Users" local group. 81 82 On earlier versions of Windows, the same feature was called "Terminal 83 Services". When invoked on such versions, this script does nothing 84 and exits successfully. 85 86 =head1 SEE ALSO 87 88 C<http://msdn.microsoft.com/library/en-us/termserv/termserv/terminal_services_wmi_provider_classes.asp>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |