windows 用于静默自动安装Java的批处理文件

ax6ht2ek  于 2023-01-21  发布在  Windows
关注(0)|答案(1)|浏览(197)

我正在写一个批自动安装Moded Minecraft(包括一切需要)。安装Java似乎很简单,但我不知道如何安装它与类似的东西wget安静。
示例:

wget {java download link}
/s java-installer.exe (basically run it silently)
then wait for it to install (which I also can't find a good way)
if exist "java.exe" (goto java-installed) else (goto java-install-failed)
then on to the rest of my code

(Any欢迎回答)
我试着从批处理中的安装程序文件安装java,但是它只是打开文件。我真的不知道从那里去哪里。理想的过程是静默安装它,并将信息从java安装程序输出到同一个命令提示符窗口和批处理文件

qnakjoqk

qnakjoqk1#

(1)下载Java,使用curl,下载Eclipse Temurin OpenJDK,而不是Oracle JDK,下载msi

curl -o OpenJDK17U-jdk_x64_windows_hotspot_17.0.4.1_1.msi "https://objects.githubusercontent.com/github-production-release-as(1) Windows Download JDK , curl -o OpenJDK17U-jdk_x64_windows_hotspot_17.0.4.1_1.msi "https://objects.githubusercontent.com/github-production-release-asset-2e65be/372925194/e265da45-c52a-4c92-9f5a-bd745ca6dee6?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230120%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230120T125513Z&X-Amz-Expires=300&X-Amz-Signature=40342838665f6a7c0bd4a8e625713477ffb06684316839609b0c7bc303c12b72&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=372925194&response-content-disposition=attachment%3B%20filename%3DOpenJDK17U-jdk_x64_windows_hotspot_17.0.4.1_1.msi&response-content-type=application%2Foctet-stream"

set-2e65be/372925194/e265da45-c52a-4c92-9f5a-bd745ca6dee6?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230120%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230120T125513Z&X-Amz-Expires=300&X-Amz-Signature=40342838665f6a7c0bd4a8e625713477ffb06684316839609b0c7bc303c12b72&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=372925194&response-content-disposition=attachment%3B%20filename%3DOpenJDK17U-jdk_x64_windows_hotspot_17.0.4.1_1.msi&response-content-type=application%2Foctet-stream"

(2)打开Cmd PromptRun as administrator

msiexec /i OpenJDK17U-jdk_x64_windows_hotspot_17.0.4.1_1.msi ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome,FeatureOracleJavaSoft /qn /l* demo.log

打开demo.log检查安装结果:
如果状态代码为0,则表示安装成功

success or error status: 0.

如果状态代码不为0,则表示安装失败。

相关问题