|
-
Nov 8th, 2004, 11:03 PM
#1
Thread Starter
Lively Member
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
Last edited by mikepol; Nov 17th, 2004 at 06:21 PM.
-
Nov 8th, 2004, 11:08 PM
#2
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 8th, 2004, 11:45 PM
#3
Thread Starter
Lively Member
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.
-
Nov 9th, 2004, 12:54 PM
#4
Can send all the commands as the second parameter?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 9th, 2004, 05:02 PM
#5
Thread Starter
Lively Member
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 >>
-
Nov 9th, 2004, 10:16 PM
#6
Write a batch file with all the commands and shell it.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 16th, 2004, 05:57 PM
#7
Thread Starter
Lively Member
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
-
Nov 17th, 2004, 06:20 PM
#8
Thread Starter
Lively Member
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..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|