This reply is too late for you, but may help someone else who is now facing a similar issue.
I just wrote a similar applications to do it but to opened CMD only
and you can replace the listCommand by
powershell -command "get-Process | format-table mainwindowtitle"
(takig care with \ to use it in java) to get all opened applications .
public String[] getEnginesFromTaskManger()
{
// listCommand is a command to get all opened CMD program like (batches,.......)
// you can test it in your CMD as powershell -command "get-Process cmd | format-table mainwindowtitle"
String listCommand = "powershell -command \"get-Process cmd | format-table mainwindowtitle\"";
try
{
String line;
// since line length for powershell output is 79
int outLen = 79;
Process p = Runtime.getRuntime().exec(listCommand);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
line = input.readLine();
System.out.println("line: " + line + "\t" + line.length());
EnginesListFromTaskManeger = new ArrayList<String>();
int i = 0;
/*
I used this outLen > 0 condition to make sure that this method will close automatically
in case of no running CMD applications and you running this from your IDE's (Eclipse, Netbeans , ......)
the powershell will not stopped so i used it. */
while(line != null && outLen > 0)
{
System.out.println("line: " + line + "\t" + line.length());
line = input.readLine().trim().toLowerCase();
outLen = line.length();
EnginesListFromTaskManeger.add(i, line);
System.out.println(EnginesListFromTaskManeger.get(i));
// EnginesListFromTaskManeger[i]=(String)input.readLine().trim();
// System.out.println("EnginesListFromTaskManeger"+ EnginesListFromTaskManeger[i]);
i++;
}
input.close();
}catch(Exception err)
{
err.printStackTrace();
}
ListFromTaskManeger = new String[EnginesListFromTaskManeger.size()];
ListFromTaskManeger = EnginesListFromTaskManeger.toArray(ListFromTaskManeger);
return ListFromTaskManeger;
}