in reply to interactive command session possible?

This cannot be done by piping characters to runas.exe stdin, because it doesn't read them from stdin, but rather fetches them directly from the process input queue.

It can however be done by writing directly to the applications input queue, using Win32::GuiTest.

#! perl -slw use strict; use Win32::GuiTest qw[ SendKeys ]; system 1, q[ runas /user:UserName "c:\path\\to\\the\\Command /switches + Args" ]; sleep 1; SendKeys( 'tHePa55W0rD~', 50 );

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: interactive command session possible?
by lisa_lionheart (Initiate) on Sep 15, 2011 at 01:06 UTC

    BrowserUk,

    Awesome suggestion. I'm going to try this first chance, but from a glance it looks pretty sound. So long as it accepts the keys, all it should take is some tweaking to the sleep value. Thanks!!!
      So long as it accepts the keys,

      SendKeys() can generate every possible character including Unicode, along with all of the non-characters keys such as the "Windows" and "Context menu" keys.

      all it should take is some tweaking to the sleep value.

      The sleep is there just to give the program time to start and display its window before the keystrokes are sent. The timing might be optimised by using WaitWindow() instead.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.