System.getProperty("os.name") //h获取名称
System.getProperty("os.version") //版本号
System.getProperty("os.arch") //架构
有没有获取安装路径的呢
System.getProperty("os.version") //版本号
System.getProperty("os.arch") //架构
有没有获取安装路径的呢
系统安装路径好像没有
try {
String[] cmd = new String[] { "cmd.exe", "/c", "path" };
process = Runtime.getRuntime().exec(cmd);
InputStreamReader ir = new InputStreamReader(process
.getInputStream());
BufferedReader br = new BufferedReader(ir);
String line;
String path="";
while ((line = br.readLine()) != null){
path+=line;
}
System.out.println(path);
path=path.substring(path.indexOf("=")+1).toLowerCase();
String[] temp=path.split(";");
for(int i=0;i<temp.length;i++){
if(temp[i].indexOf("windows")!=-1){
path=path.substring(0,temp[i].indexOf(":"));
break;
}
}
System.out.println(path);
} catch (java.io.IOException e) {
System.err.println("IOException " + e.getMessage());
e.printStackTrace();
}
}这样可以看出系统装在哪个盘上,但是遇到特殊情况也有漏洞,多加几道验证应该好点不知道ms-dos下有没有类似的命令,可以用runtime来执行,获取系统路径