Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Perl Programming Language

Querying for a registry string VALUE AutoEndTasks


Hi guys would love your help.

I have the following....

=================================================================
#use Win32::Process;
use Win32::Registry;
open (INPUT,"machines.txt") or die "cant open machine.txt";
@computers = <INPUT>;

      while (<INPUT>){
            chomp;
            push @computers, $_;
                         }
       foreach $computer(@computers) {
                          print "Connecting to ....... $computer\n";
      $rc = system ("net use \\\\$computer\\ipc\$ /user:domain\\user
password> NUL");
         if ($rc ==0){                # If the connection succeeds
               print "Connected to $computer\n";
               QueryAutoEndTasksReg;
         print " AutoEndTasks = $AutoValue\n";
                  }
      elsif (!rc ==0) {                                                # If
the connection fails......
            print "Failed to connect to $computer\n\n";
      }

}

sub QueryAutoEndTasksReg {
    $p = '.DEFAULT\Control Panel\Desktop';
    Win32::RegOpenKeyEx(&HKEY_USERS,$p,&NULL,&KEY_ALL_ACCESS,$hkey);
    Win32::RegQueryValueEx($hkey,"AutoEndTasks",&NULL,$type,$AutoValue);
#    Win32::RegCloseKey($hkey);

  }

================================================================= Output at
the moment is this...

C:\Test>test.pl
Connecting to ....... machine1

The command completed successfully.

Connected to machine1

 AutoEndTasks =
Connecting to ....... machine2

System error 53 has occurred.

The network path was not found.

Failed to connect ot machine2

Connecting to ....... machine3

The command completed successfully.

Connected to machine3

 AutoEndTasks =

C:\Test>

=====================================================

What Im trying to do is query the following registry string VALUE
AutoEndTasks on all systems in a machine.txt file...

HKEY_USERS\.DEFAULT\Control Panel\Desktop\AutoEndTasks

I have a feeling I have the format wrong in my sub..

sub QueryAutoEndTasksReg {
    $p = '.DEFAULT\Control Panel\Desktop';
    Win32::RegOpenKeyEx(&HKEY_USERS,$p,&NULL,&KEY_ALL_ACCESS,$hkey);
    Win32::RegQueryValueEx($hkey,"AutoEndTasks",&NULL,$type,$AutoValue);
#Im not sure if I have this correct.
#    Win32::RegCloseKey($hkey);

  }

If someone could offer some advice, that would be great.

Thank you.

S

possible issueSimonH wrote:
> Hi guys would love your help.

> I have the following....

> =================================================================
> #use Win32::Process;

use strict;
use warnings;

> use Win32::Registry;
> open (INPUT,"machines.txt") or die "cant open machine.txt";
> @computers = <INPUT>;

This reads the entire file into @computers.

>       while (<INPUT>){

There's nothing left to read, so this is useless.

>             chomp;
>             push @computers, $_;
>                          }
>        foreach $computer(@computers) {

Replace the foreach with the while above, without the push.  No
need to read the entire file into @computers.

        while( chomp( my $computer = <INPUT> ) )

>                           print "Connecting to ....... $computer\n";
>       $rc = system ("net use \\\\$computer\\ipc\$ /user:domain\\user
> password> NUL");
>          if ($rc ==0){                # If the connection succeeds
>                print "Connected to $computer\n";
>                QueryAutoEndTasksReg;
>          print " AutoEndTasks = $AutoValue\n";
>                   }
>       elsif (!rc ==0) {  

Missing a '$' there... actually, no condition is needed.  Either it's 0,
as above, or it isn't, so simply an else will suffice.

                                               # If

> the connection fails......
>             print "Failed to connect to $computer\n\n";
>       }
> }

> sub QueryAutoEndTasksReg {
>     $p = '.DEFAULT\Control Panel\Desktop';
>     Win32::RegOpenKeyEx(&HKEY_USERS,$p,&NULL,&KEY_ALL_ACCESS,$hkey);
>     Win32::RegQueryValueEx($hkey,"AutoEndTasks",&NULL,$type,$AutoValue);
> #    Win32::RegCloseKey($hkey);

>   }

No idea what's really wrong, just pointing out obvious things.

SimonH wrote:
> Hi guys would love your help.

> I have the following....

> =================================================================
> #use Win32::Process;
> use Win32::Registry;

Please for  what is the "AutoEndTasks" registry key mean?
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

Hi Petr!

Its a created string value for forcing applications that wont close to
close.

"Petr Vileta" <sto@practisoft.cz> wrote in message

news:f4ago0$2vn3$1@ns.felk.cvut.cz...

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc