[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-unattended/var/se3/unattended/install/bin/ -> instsrv.pl (source)

   1  # Like "instsrv", but require an account and prompt for the password.
   2  
   3  use warnings;
   4  use strict;
   5  use Win32::OLE;
   6  #use Term::ReadKey;
   7  
   8  @ARGV == 3
   9      or die "usage: $0 <service> <command> <account name>\n";
  10  
  11  my ($service, $cmd, $acct) = @ARGV;
  12  
  13  print "*** Now configuring $service\n";
  14  
  15  #ReadMode 2;
  16  
  17  my $pass;
  18  while (1) {
  19      print "Enter password for $acct: ";
  20      $pass = <STDIN>;
  21      chomp $pass;
  22  #    print "\nRe-type password: ";
  23  #    my $pass2 = <STDIN>;
  24      my $pass2 = $pass;
  25  #    chomp $pass2;
  26      $pass eq $pass2
  27          and last;
  28      print "Passwords do not match!\nTry again.\n\n";
  29  }
  30  
  31  #ReadMode 0;
  32  
  33  # Bomb out completely if COM engine encounters any trouble.
  34  Win32::OLE->Option ('Warn' => 3);
  35  
  36  # Get the Win32_Service class.
  37  # <http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_service.asp>
  38  my $srv_class = Win32::OLE->GetObject ('WinMgmts:Win32_Service');
  39  my $ret = $srv_class->Create
  40      ($service,
  41       $service,
  42       $cmd,
  43       16,
  44       1,
  45       'Automatic',
  46       0,
  47       $acct,
  48       $pass
  49       );
  50  
  51  $ret == 0
  52      or die "Win32_Service::Create failed; code == $ret";
  53  
  54  exit 0;


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1