这就是我的方式。我将程序文件\ Heimdall添加到注册表...
String GetReg[]={"reg", "query", "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", "/v", "Path"};
String RegVal="";
try {
RegVal =Shell.sendShellCommand(GetReg).split(" ")[2].replace("\n", "");
} catch (ArrayIndexOutOfBoundsException e){
RegVal = Shell.sendShellCommand(GetReg).split(" ")[2].replace("\n", "");
}
if ((RegVal.contains("C:\\")) || (RegVal.contains(";%SystemRoot%"))){
String RegPATH=RegVal+ProgramFiles+"\\Heimdall\\;";
Log.level3(RegVal);
Log.level2("Attempting to insert" + RegPATH + "into Registry");
String RegCommand[]={"reg", "add","HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", "/v", "Path" ,"/t" ,"REG_EXPAND_SZ", "/d", "\""+RegPATH+"\"" , "/f"};
if (! RegVal.contains(ProgramFiles+"\\Heimdall\\")){
Shell.sendShellCommand(RegCommand);
}
}