Process p;
if (File.separator.equals("\\")) {
p = Runtime.getRuntime().exec("cmd /c set");
} else {
p = Runtime.getRuntime().exec("printenv");
}
InputStream in = p.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line;
Hashtable table = new Hashtable();
while ((line = reader.readLine()) != null) {
int i = line.indexOf('=");
if (i > 0) {
String name = line.substring(0, i);
String value = line.substring(i+1);
table.put(name, value);
}
}
in.close();
p.waitFor();
return table;