直接修改注册表,然后刷新注册表,再用下Envupdate。
这个是我一段用来注册jdk路径的部分代码,可以参照下。
$JDKVersion=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit","CurrentVersion")
$JDKPath1=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\"&$JDKVersion,"JavaHome")
$JDKPath=$JDKPath1&"\bin"
$OriginalPath=EnvGet("path")
RegWrite("HKEY_CURRENT_USER\Environment", "classpath", "REG_SZ", ".;" & $JDKPath & "\lib\tools.jar;" & $JDKPath & "\lib\dt.jar")
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","Path","REG_EXPAND_SZ","")
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","Path","REG_EXPAND_SZ",$JDKPath&";"&$OriginalPath)
DllCall("shell32.dll", "none", "SHChangeNotify", "long", 0x8000000, "int", 0, "ptr", 0, "ptr", 0)
EnvUpdate()
Exit |