How to get the output of multiple processes

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,<br/>

Our company has bought couple of hundred android devices and before these can be sent to end users an application has to be installed. To avoid installing each device manually, Im trying to write some code that does the installation for me.
After some researching and testing Ive end up using <span style="color:#333333; font-family:arial,sans-serif; font-size:13px; line-height:16px
Android Debug Bridge (adb) tool to install the device and USB hub so that I can connect multiple devices to computer at once.
I have written a simple Windows Forms Application where one button gets the list of connected devices and other loops through them installing and reading the output one by one.
Install:
System.Diagnostics.Process p = new System.Diagnostics.Process();<br/>
p.StartInfo.UseShellExecute = false;<br/>
p.StartInfo.FileName = "cmd.exe";<br/>
p.StartInfo.WorkingDirectory = "Dir";<br/>
p.StartInfo.RedirectStandardError = true;<br/>
p.StartInfo.RedirectStandardInput = true;<br/>
p.StartInfo.RedirectStandardOutput = true;<br/>
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
<span style="white-space:pre p.StartInfo.CreateNoWindow = true;
string Devicelist = textBox1.Text;<br/>
string[] IMEI = Devicelist.Split(new string[] { "rn", "t" }, StringSplitOptions.RemoveEmptyEntries);
<span style="white-space:pre textBox1.Text = "";
for (int i = 0; i < IMEI.Length; i++)<br/>

{<br/>
p.StartInfo.Arguments = @"/c adb -s " + IMEI + " install Program.apk";<br/>
p.Start();<br/>
<br/>
string Statuslist = p.StandardOutput.ReadToEnd();<br/>
string[] Status= Statuslist.Split(new string[] { "rn", "t" }, StringSplitOptions.RemoveEmptyEntries);<br/>
<br/>
textBox1.Text = textBox1.Text + "rn" + IMEI + "t" + Status[1]; <br/>
}

This does what it should be but its not that effective. Now it installs devices one by one.
I would like to start all the installation processes at once and read the outputs when the installations are done.
The former I can accomplish by erasing or moving output lines outside the for loop. The latter seems the be more difficult for me. I can only get the output of the latest process.
Please advice how to get the output of all the processes?

Br,<br/>

Tupe

View the full article
 
Back
Top