Querying for a registry string VALUE AutoEndTasks

S

SimonH

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

J. Gleixner

possible said:
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 = said:
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.
 
S

SimonH

Hi Petr!

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top