-
keep cmd in focus
Hi All,
I'm executing a Shell() command to open a cmd terminal execute a file with arguments to login to a server. Now that works all fine. The problem arises when I try to send subsequent commands to the open connection because the cmd terminal closes as soon as the command is executed...
so, in a typical cmd terminal box, I would execute the login command, as soon as it connects, it feeds a line and expects commands to be thrown at it.. it's kindof like a socket connection except it's got some funny login handling, which is why i'm not using winsock1.
so is there a way I can keep the focus to the cmd prompt open, so that I can feed it commands after the initial login connection??
thanks a lot
Mike
-
If you shell the CMD.exe with /K (Keep open) and your bat file as
the second parameter it will accomplish what you want. You will
probably need to use complete file paths for all.
HTH
-
thanks for the reply!
It worked half way -
I executed cmd.exe /k and sent the inital parameters as a second argument and it worked fine.
my issue is that I then want to send subsequent strings to the open cmd window.. they are not program names as such, but commands that are to be sent to the program that expects them to come in via the opened cmd window.
getting there- just one more step..
THANKS!
m.
-
Can send all the commands as the second parameter?
-
I wish I could, that would be the end of the problem :)
what happens is that using the second parameter, I simply 'login' to the program that I'm interfacing with, then the subsequent commands that I send to the program are sent after the login has authenticated... and those subsequent commands are expected to be sent form the same cmd terminal window that initiated the login...
I guess all I need to do is to target the same cmd window and send strings to it... strings that are not executables or commands as such but strings that are expected to be accepted...
my head right now >> :eek2:
-
Write a batch file with all the commands and shell it.
-
okay, after a longish stint off because of other things, I finally did this.
i placed the logon string as the first command, followed by a carriage return and the string that is to be sent to the logged in connection
what happens is that the first commad executes fine and 'holds' the connection open, so that the second line of the bat file nexer executes, it's as if the first command executes and does not come back to the prompt to be able to execute the second command in the bat file...
how can I send additional strings to the opened program in the cmd window?
thanks for the help robDog
-
i ended up using an ugly work around
used FindWindow to get the cmd box handle and SendKeys to send subsequent strings/commands to it..