Powershell 静默安装 Java

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29799158/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 08:37:43  来源:igfitidea点击:

Powershell install Java silently

javapowershell

提问by Jerry1

I need to install new Java update silently. I have these arguments for installation:

我需要静默安装新的 Java 更新。我有这些安装参数:

INSTALL_SILENT=1 STATIC=0 AUTO_UPDATE=0 WEB_JAVA=1 WEB_JAVA_SECURITY_LEVEL=H WEB_ANALYTICS=0 EULA=0 REBOOT=0 NOSTARTMENU=0 SPONSORS=0

and I tried:

我试过:

Start-Process -Wait '\srv\netlogon\java\jre-8u45-windows-i586.exe' -ArgumentList '/s INSTALL_SILENT=1 STATIC=0 AUTO_UPDATE=0 WEB_JAVA=1 WEB_JAVA_SECURITY_LEVEL=H WEB_ANALYTICS=0 EULA=0 REBOOT=0 NOSTARTMENU=0 SPONSORS=0'

and also:

并且:

$arguments = @(
    '/s',
    "/v/qn `"INSTALL_SILENT=1 STATIC=0 AUTO_UPDATE=0 WEB_JAVA=1 WEB_JAVA_SECURITY_LEVEL=H WEB_ANALYTICS=0 EULA=0 REBOOT=0 NOSTARTMENU=0 SPONSORS=0 /L \`"c:\temp\java_install.log\`"`""
)

$proc = Start-Process "\srv\netlogon\java\jre-8u45-windows-i586.exe" -ArgumentList $arguments -Wait -PassThru
if($proc.ExitCode -ne 0) {
    Throw "ERROR"
}

and both version has prompt dialog. How to install it silently?

并且两个版本都有提示对话框。如何静默安装?

采纳答案by Jerry1

I found solution in cmdLet Execute-Processvia this script. Works fine!

Execute-Process通过这个脚本在 cmdLet 中找到了解决方案。工作正常!

And calling it:

并称之为:

Execute-Process '\srv\java\jre-8u45-windows-x64.exe' -Arguments '/s INSTALL_SILENT=1 STATIC=0 AUTO_UPDATE=0 WEB_JAVA=1 WEB_JAVA_SECURITY_LEVEL=H WEB_ANALYTICS=0 EULA=0 REBOOT=0 NOSTARTMENU=0 SPONSORS=0 /L c:\temp\jre-8u45-windows-x64.log'

回答by SubOptimal

The option you pass to the installer are only valid for an installation configuration file. If you do not want to use a configuration file you can use the following command line options for a silent install.

您传递给安装程序的选项仅对安装配置文件有效。如果不想使用配置文件,可以使用以下命令行选项进行静默安装