总结一下我想要实现的目标,我想查询 2 个键,如果它们存在,则转到批处理文件的末尾,如果不安装 Java。
批处理文件可以正常安装 Java,但是在测试我是否删除 .txt 文件时:
IF exist %windir%\gpologs\jre_1.7.21.x86.txt goto eof ELSE goto Q1
即使存在其中一个注册表项,安装程序仍试图安装在顶部?
这是完整的批处理文件:
IF exist %windir%\grouppolicylogs\jre_1.7.21.x86.txt goto eof ELSE goto Q1
:Q1
Reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F86417025FF}"
if %ErrorLevel% EQU == 0 goto End ELSE goto Q2
:Q2
Reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F83217021FF}"
if %ErrorLevel% EQU == 0 goto End ELSE goto Install
:Install
msiexec /i "\\servername\SoftwareRep\Java\Java 1.7.0_21 x86\jre1.7.0_21.msi" /qn
if %ErrorLevel% EQU 0 (
>>"\\servername\gpolog\jre_1.7.21.x86.csv" echo "%computername%","%date%","%Time%","%ErrorLevel%","Java Runtime 1.7.0_21x86 Installed"
>>"%windir%\GpoLogs\jre_1.7.21.x86.txt" echo "Java Runtime 1.7.0_21x86 Installed"
) else (
>>"\\servername\gpolog\JavaInstallErrors.csv" echo "%computername%","%date%","%Time%","%ErrorLevel%","Error trying to install Java 1.7_21x86"
)
:END
我哪里错了?