Process p = null; Properties envVars = new Properties (); Runtime r = Runtime.getRuntime (); try {p = r.exec ( "cmd.exe / c set user"); BufferedReader br = new BufferedReader (new InputStreamReader ( p.GETINPUTSTREAM ()); string line; // The first line is the machine name; the second line is the username currently logged in, // The third is the main folder while of the current login user ((line = Br. Readline ())! = NULL) {Int idx = line.indexof ('='); string key = line.substring (0, idx); string value = line.substring (IDX 1); Envvars.SetProperty (Key , value); System.out.println (key "=" value);}} catch (exception e) {E.PrintStackTrace ();}