Querying for a registry string VALUE AutoEndTasks

Discussion in 'Perl Misc' started by SimonH, Jun 7, 2007.

  1. SimonH

    SimonH Guest

    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
    SimonH, Jun 7, 2007
    #1
    1. Advertising

  2. SimonH

    J. Gleixner Guest

    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.
    J. Gleixner, Jun 7, 2007
    #2
    1. Advertising

  3. SimonH

    SimonH Guest

    Hi Petr!

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


    "Petr Vileta" <> wrote in message
    news:f4ago0$2vn3$...
    > 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.)
    >
    >
    >
    SimonH, Jun 9, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HK
    Replies:
    1
    Views:
    3,604
    Cowboy \(Gregory A. Beamer\)
    Apr 1, 2004
  2. Replies:
    0
    Views:
    730
  3. Leny
    Replies:
    3
    Views:
    16,901
    Daniel
    Feb 1, 2005
  4. Rahul Chatterjee

    querying a disabled value

    Rahul Chatterjee, Apr 20, 2004, in forum: ASP General
    Replies:
    3
    Views:
    95
    Ray at
    Apr 20, 2004
  5. Collin Miller
    Replies:
    10
    Views:
    576
    Roger Pack
    Jul 9, 2010
Loading...

Share This Page