odd behavior between Guitest and rcmd on windows

Discussion in 'Perl Misc' started by Mark Seger, Mar 9, 2007.

  1. Mark Seger

    Mark Seger Guest

    I have a testing environment that is set up in such a way that after
    logging into the PC, a window is displayed that waits for the user to
    hit the ENTER key and then automaticall starts running a canned set of
    tests. This system also has rcmd set up on it for doing various mgmt
    tasks such as rebooting it. What I'd like to do is use rcmd to remotely
    run a local program that sends the ENTER to the system and so remotely
    start the tests running.

    So, having discovered GuiTest, I wrote a very simple script that looks
    for the window named 'Test' that's waiting on the the ENTER key, selects
    it and does a SendKey of {ENTER}. Works great when testing it locally
    on that test machine but when I run it remotely via rcmd the call that
    sets the foregoround window fails.

    My initial thought is that the reason is because the script isn't
    associated with any windows and therefore may not have the appropriate
    context to find any other windows. To test this I used rcmd to simply
    create an 'at' job but when that kicked off it too failed. I also tried
    running the script via "cmd /c scriptname" to give it a windows context
    but that fails too. Anybody ever see this sort of behavior before?

    Here's what my script looks like, with the line of code that tells me
    '$window' is undefined. This only happens when run via rcmd.

    #!/usr/bin/perl

    use strict;
    use warnings;
    use Win32::GuiTest qw(FindWindowLike SendKeys SetForegroundWindow);

    my ($window) = FindWindowLike(0, '^Test');
    print "Can't find window!!!\n" if !defined($window);
    SetForegroundWindow($window);
    SendKeys('{ENTER}');

    -mark
    Mark Seger, Mar 9, 2007
    #1
    1. Advertising

  2. Mark Seger <> wrote in news:essaso$lsa$:

    > I have a testing environment that is set up in such a way that after
    > logging into the PC, a window is displayed that waits for the user to
    > hit the ENTER key and then automaticall starts running a canned set of
    > tests. This system also has rcmd set up on it for doing various mgmt
    > tasks such as rebooting it. What I'd like to do is use rcmd to
    > remotely run a local program that sends the ENTER to the system and so
    > remotely start the tests running.


    You should not assume that everyone knows what rcmd is. According to

    http://www.microsoft.com/technet/archive/winntas/support/advtshoot/x0a_tool.mspx?mfr=true

    it allows you to interact with a Windows service that allows you to
    run commands remotely on a computer.

    AFAIK, services don't automatically have the right to interact with the
    desktop.

    For your script, started using rcmd, to be able to interact with the
    desktop, you'll need to set it up that way.

    I don't know much about how to do that and as such this is not a Perl
    problem.

    You might find useful information at

    http://support.microsoft.com/kb/327618

    Sinan
    A. Sinan Unur, Mar 10, 2007
    #2
    1. Advertising

  3. Mark Seger

    Mark Seger Guest

    A. Sinan Unur wrote:
    > Mark Seger <> wrote in news:essaso$lsa$:
    >
    >> I have a testing environment that is set up in such a way that after
    >> logging into the PC, a window is displayed that waits for the user to
    >> hit the ENTER key and then automaticall starts running a canned set of
    >> tests. This system also has rcmd set up on it for doing various mgmt
    >> tasks such as rebooting it. What I'd like to do is use rcmd to
    >> remotely run a local program that sends the ENTER to the system and so
    >> remotely start the tests running.

    >
    > You should not assume that everyone knows what rcmd is. According to
    >
    > http://www.microsoft.com/technet/archive/winntas/support/advtshoot/x0a_tool.mspx?mfr=true
    >
    > it allows you to interact with a Windows service that allows you to
    > run commands remotely on a computer.
    >
    > AFAIK, services don't automatically have the right to interact with the
    > desktop.
    >
    > For your script, started using rcmd, to be able to interact with the
    > desktop, you'll need to set it up that way.
    >
    > I don't know much about how to do that and as such this is not a Perl
    > problem.
    >
    > You might find useful information at
    >
    > http://support.microsoft.com/kb/327618
    >
    > Sinan

    Thanks, Sinan. I thought you might reply to me since I had originally
    found some reponses you had made to a different poster on how to use
    GuiTest. :cool:

    Good suggestion about trying microsoft though I'm not hopeful as I
    suspect it's real users who can help - but maybe a microsoft newsgroup
    is the way to do. Meanwhile I can also use GuiTest to move the mouse to
    a specific screen location, essentially putting it over the OK button,
    and doing a mouse click. That may help, though I'm not really fond of it.

    -mark
    Mark Seger, Mar 10, 2007
    #3
  4. Mark Seger

    Csaba Guest

    "A. Sinan Unur" <> wrote in
    news:Xns98EED163F596Casu1cornelledu@127.0.0.1:

    > Mark Seger <> wrote in
    > news:essaso$lsa$:
    >
    >> I have a testing environment that is set up in such a way that after
    >> logging into the PC, a window is displayed that waits for the user to
    >> hit the ENTER key and then automaticall starts running a canned set
    >> of tests. This system also has rcmd set up on it for doing various
    >> mgmt tasks such as rebooting it. What I'd like to do is use rcmd to
    >> remotely run a local program that sends the ENTER to the system and
    >> so remotely start the tests running.

    [snip]
    >
    > AFAIK, services don't automatically have the right to interact with
    > the desktop.
    >
    > For your script, started using rcmd, to be able to interact with the
    > desktop, you'll need to set it up that way.


    Also, the service (and everything started from it) might have a
    completely different desktop from the one containing the window with the
    button you want to press. Try changing the account for the service to be
    the same as the user logged in interactively.

    --
    Life is complex, with real and imaginary parts.
    Csaba, Mar 17, 2007
    #4
    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. David Mathog

    OT: rcmd() fails on second call if not root

    David Mathog, Jun 16, 2005, in forum: C Programming
    Replies:
    1
    Views:
    317
    Keith Thompson
    Jun 16, 2005
  2. Michael Speer

    Odd behavior with odd code

    Michael Speer, Feb 16, 2007, in forum: C Programming
    Replies:
    33
    Views:
    1,048
    Richard Heathfield
    Feb 18, 2007
  3. Allton, Paul

    win32-guitest

    Allton, Paul, Nov 12, 2004, in forum: Ruby
    Replies:
    1
    Views:
    128
    Chad Fowler
    Nov 12, 2004
  4. gw1500se
    Replies:
    5
    Views:
    126
    gw1500se
    Jul 6, 2003
  5. Tom

    Win32-GuiTest and waits

    Tom, May 12, 2004, in forum: Perl Misc
    Replies:
    0
    Views:
    96
Loading...

Share This Page