Sysinternals Homepage
Forum Home Forum Home > Sysinternals Utilities > PsTools
  New Posts New Posts RSS Feed - Psexec - input redirection to a remote exe - is th
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Psexec - input redirection to a remote exe - is th

 Post Reply Post Reply
Author
Message
kirannhegde View Drop Down
Newbie
Newbie


Joined: 03 August 2012
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote kirannhegde Quote  Post ReplyReply Direct Link To This Post Topic: Psexec - input redirection to a remote exe - is th
    Posted: 04 October 2012 at 7:00am

Description of my scenario: I am using PsExec to remotely launch an in house utility which prints certain records on the command prompt. When this utility is launched on the command prompt by logging into the remote server, the utility works fine. It is able to print all the records which is expected out of it. However, when the utility is launched remotely using Psexec , the utility hangs. Basically this is what we do to launch the exe remotely: i)Connect to the remote server as an adminstrator using psexec and open a remote cmd.exe psexec \ -u -p cmd.exe ii)Launch the utility from the remote cmd.exe

Upon further investigation, it was found out that the utility makes use of an API called ReadConsoleInput(). (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684961(v=vs.85).aspx) There is logic in the utility to print records on the command prompt with a page size of 23 records and then waits for the user input.ReadConsoleInput() waits for an user input before the next page of records is displayed. This API does not return until at least one record is read from the Console input buffer. Since Psexec does not redirect the keystrokes back to the remote server, the function waits indefinitely.This results in a hang.

Is this a known issue? If yes, how do i get this scenario working? Any alternatives? Are there any documented workarounds?

Any help would be very much appreciated.

Thanks

Back to Top
spatters View Drop Down
Newbie
Newbie
Avatar

Joined: 27 September 2012
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote spatters Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2012 at 12:33pm
I think maybe if you call the utility in another thread using the start command it will work

For example, instead of this...
utility.exe[/CODE]

...do this...
[CODE]start utility.exe


...which will kick off utility under a separate command prompt that doesn't have input redirection.
Back to Top
spatters View Drop Down
Newbie
Newbie
Avatar

Joined: 27 September 2012
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote spatters Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2012 at 12:35pm
<brag>BTW here is a batch file I wrote that makes great use of this concept</brag> :)
Back to Top
kirannhegde View Drop Down
Newbie
Newbie


Joined: 03 August 2012
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote kirannhegde Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2012 at 9:01am
Hello,

Thanks for the responses.
Could you kindly clarify on what you mean with your above statements?

Regards,
Kiran Hegde
Back to Top
aaronmar View Drop Down
Moderator Group
Moderator Group


Joined: 13 July 2010
Status: Offline
Points: 66
Post Options Post Options   Thanks (0) Thanks(0)   Quote aaronmar Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2012 at 6:53pm
My guess (just a guess) is that if the console app doesn't accept redirection of standard input and only accepts actual console input, it's going to be stuck.  Any chance it could be rewritten to accept standard input instead of insisting on console input?
-- Aaron Margosis (Microsoft)
co-author of The Windows Sysinternals Administrator's Reference.
http://www.amazon.com/Windows-Sysinternals-Administrators-Reference-Russinovich/dp/073565672X
Back to Top
kirannhegde View Drop Down
Newbie
Newbie


Joined: 03 August 2012
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote kirannhegde Quote  Post ReplyReply Direct Link To This Post Posted: 10 October 2012 at 5:19am
Let me see if that is an option to get this issue fixed.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down