%SystemRoot% 的值就是安装目录,%windir%也对,怎么会取不到呢?
根据Process p = Runtime.getRuntime().exec("echo %windir%");
然后p.getInputStream() 读出这里的内容应该就可以了.

解决方案 »

  1.   

    Try yourself, it's not work.
      

  2.   

    String windir = System.getenv("windir");
      

  3.   

    jdk1.4.x中此方法的源码是:public static String getenv(String name) {
    throw new Error("getenv no longer supported, use properties and -D instead: " + name);
        }所以无法调用此方法。
      

  4.   

    把echo %windir%写到一个bat里面再执行就行了。
    谢谢各位的回贴。