You should put in some error-checking.  

if($nKey= $Registry->{"//$machine/LMachine/Software/KEYA "}){
   print "Registry Connected\n";
}else{
   print "Could not connect to Registry.\n";
}

If you aren't successful connecting to the registry, then it's pointless to
go through trying to manipulate keys that don't exist.  Likewise with the
services.

-----Original Message-----
From: Conor Lillis
To: 'Fifield, Mike'; [EMAIL PROTECTED]
Sent: 3/20/02 7:05 AM
Subject: RE: Getting a machine to time out...

What I do is put in a line that checks you can enumerate the services,
then it is dependant on you having the admin rights to manipulate the
services...
 
 if (!Win32::Service::GetServices($PC,\%services)) 
 {
  print "$PC services not accessible via the network\n";
 }
 else 
[Your stuff here]
 
 
 -----Original Message-----
From: Fifield, Mike [mailto:[EMAIL PROTECTED]]
Sent: 20 March 2002 14:25
To: '[EMAIL PROTECTED]'
Subject: Getting a machine to time out...



I am working on a script that connects to a about 3000 machines and
first modifies the registry then stops and restarts a service then moves
to the next machine. The problem I have run in to is that the script
will hang on some machines indefinitely. I thought to ping the machines
first but this does not solve the problem because some of the machines
answer a ping but still hang. I am looking for a way to set a time limit
of say 5 seconds per machine so that if the changes can not be made in
that amount of time the script will stop, and go to the next machine.

 

use Win32::Service;

use Win32::NetAdmin;

use Win32::TieRegistry (Delimiter => '/');

Win32::NetAdmin::GetServers("","", SV_TYPE_WORKSTATION, \@List);

 

########################################################################
#################

foreach $machine (@List){

            if (-e ("\\\\$machine\\c\$\\temp\\LOG.txt")){

                        unlink ("\\\\$machine\\c\$\\temp\\LOG.txt");

            }

            $nKey= $Registry->{"//$machine/LMachine/Software/KEYA "};

            $nKey->{"INFO"}= ["0x00000000","REG_DWORD"];

            print "$machine\n";

 

            $sKey= $Registry->{"//$machine/LMachine/Software/KEY1"};


            $sKey->{"INFO/"}= {

                        "INFO" => {

                        "/Description" => "INFO",

                        "/PackageDate" => "02/05/2002",

            "/Status" => "Installed",

           }

            };

            open(OUT, ">\\\\$machine\\c\$\\LOG.txt");

            open(OUT4, ">>machines_updated.txt");

            print OUT4 "$machine\n";

            Win32::Service::StopService($machine, SERVICE);

            Win32::Service::StopService($machine, SERVICE);

            

            $one = `rcmd \\\\$machine "c:\\bin\\kill.exe APP.exe"`;

            print OUT "$one";

            Win32::Service::StartService($machine, SERVICE);

            Win32::Service::StartService($machine, SERVICE);

            

            $two = `rcmd \\\\$machine c:\\progra~1\\ APP.exe`;

            print OUT "$two";

            

            

            if(Win32::Service::StopService($machine, SERVICE)){

                                    sleep 10;                       

            $three = `rcmd \\\\$machine instsrv service REMOVE
c:\\winnt\\system32\\APP.EXE`;

            print OUT "$three";

            

            unlink ("\\\\$machine\\c\$\\winnt\\system32\\APP1.EXE");

            unlink ("\\\\$machine\\c\$\\winnt\\system32\\APP2.DLL");

            unlink ("\\\\$machine\\c\$\\winnt\\system32\\APP3.INI");

            close(OUT);

}

} 

 

 

 

Mike Fifield

Charles Schwab & Co, Inc.

WARNING: All e-mail sent to or from this address will be received by the
Charles Schwab corporate e-mail system and is subject to archival and
review by someone other than the recipient.

 



The information in this email is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this
email by anyone else is unauthorised.if you are not the intended
recipient, any disclosure, copying, distribution, or any action taken or
omitted to be taken in reliance on it is prohibited and may be unlawful.
Please note that any views, opinions or advice contained in this email
are those of the sending individual and not necessarily those of the
firm. It is possible for data transmitted by e-mail to be deliberately
or accidentally corrupted or intercepted. For this reason, where the
communication is by e-mail, J&E Davy does not accept any responsibility
for any breach of confidence which may arise from the use of this
medium. If you have received this e-mail in error please notify us
immediately at mailto:[EMAIL PROTECTED] and delete this e-mail from your
system.



--------------------------------------------------------------------------------
This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to