Psexec - input redirection to a remote exe - is this a known issue
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Psexec - input redirection to a remote exe - is this a known issue

  1. #1
    Join Date
    Oct 2012
    Posts
    1

    Psexec - input redirection to a remote exe - is this a known issue

    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/libr...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
    Kiran Hegde

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,978

    Re: Psexec - input redirection to a remote exe - is this a known issue

    this isn't really what psexec was designed to to, it really is a limited functionality to launching the exe and then having it run on it's own without UI.

    If you need to take control of a remote pc, then you really should be looking for remote desktop services (taking over the pc entirely, or creating separate windows sessions in a windows server) or 'remote assistance' (sharing a desktop with the interactive user, you can see what he's doing and way around).

  3. #3
    Join Date
    Nov 2003
    Posts
    1,814

    Re: Psexec - input redirection to a remote exe - is this a known issue

    I would try calling _isatty() to see if you are running under a real console or a redirected one. If redirected, don't call Win32 console functions like ReadConsoleInput().

    http://msdn.microsoft.com/en-us/library/f4s0ddew.aspx

    gg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center