I have a cmd running 'via' a pipe, created like this:
console:=TProcess.Create(Nil);
console.Commandline:='cmd.exe';
console.Options:=[poUsePipes,poNoConsole,poStderrToOutPut];
console.CurrentDirectory:=apppath+'data\';
console.ShowWindow:=swoHIDE;
console.execute;
Now, my problem is that I'm using cmd to send commands to android device through adb (which is another command line tool). While cmd window itself is hidden, each adb call creates new console window which shortly after closes automatically. How do I hide all those windows altogether?
Every time you execute adb.exe
, it needs to start a new instance of cmd.exe
if not already being called by cmd.exe
. So, for what you are attempting, simply run cmd.exe
one time and keep the session open, and then write commands to it (like ADB commands) over the existing STDIN pipe using the TProcess.Input
property.
Better still, you could implement the ADB protocol directly in your own code, communicating over a TCP/USB connection to the device itself. Then you wouldn't need to run adb.exe
at all.
Or, to make things a bit simpler, you could run adb.exe
as a local server and then communicate with it over a TCP connection instead of through cmd.exe
. This is what adb.exe
does internally when it is run as a client.