My code so far:
public static void getTasklist(Table table, Login login){
for(TableItem tableItem : table.getItems()){
try {
if(tableItem.getChecked()){
String command = ("cmd.exe /k tasklist /s " + tableItem.getText(3) + " /U .\\" + SettingsManager.getSetting(login, "Current-User") + " /p " + SettingsManager.getSetting(login, SettingsManager.getSetting(login, "Current-User")+"-PW"));
Process p = Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
}
}
catch (IOException e) {
}
}
}
What I want to do: get task list information from a computer and print it to console (later print it to a window maybe). The host name from the computer comes from the checked table (tableItem.getText(3)
) and the credentials comes from something I called settingsmanager
(SettingsManager.getSetting....
).
What works ATM: I get the Information and it got printed to console but after the last line the app hangs up.. I assume that the while loop never breaks but I am not sure about that..