Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Querying for a registry string VALUE AutoEndTasks (http://www.velocityreviews.com/forums/t903382-querying-for-a-registry-string-value-autoendtasks.html)

SimonH 06-07-2007 12:11 PM

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




J. Gleixner 06-07-2007 03:21 PM

Re: Querying for a registry string VALUE AutoEndTasks
 
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 06-09-2007 02:09 AM

Re: Querying for a registry string VALUE AutoEndTasks
 
Hi Petr!

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


"Petr Vileta" <stoupa@practisoft.cz> wrote in message
news:f4ago0$2vn3$1@ns.felk.cvut.cz...
> 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.)
>
>
>





All times are GMT. The time now is 02:18 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.