Question

I have this batch file:

 @echo off
 echo c:\temp\MyProgram.exe > commands.txt
 runas /profile /savecred /user:user1 "cmd /k remote /c computerB session_1 < commands.txt"
 ....

Explication:
I connect remotley to comupterB with the user1 and execute MyProgram.exe (That is in computerB). MyProgram.exe execute in console and wait action from the user (Type arguments). The problem is I'm not able to type anything from keyboard in MyProgram console, it seems the keyboard is ignored completly !.
I know that I must switch to stdin=0 for keyboard but I don't know how to do.
Thanks

Was it helpful?

Solution

When you redirect stdin with cmd /k ... < commands.txt, you're losing stdin. Why would you expect to get it back? All child processes inherit their base (0, 1, and 2) file descriptors.

Is commands.txt a batch file? If so, why not run it instead of redirect commands from it? You could copy that file to the remote machine, then invoke it, leaving cmd open.

runas /user:user1 "cmd /k remote /c computerB session_1 call c:\temp\commands.cmd"

When I do this, the cmd window is still left open and I can type into it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top