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
Powershell install Java silently
提问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-Process
via 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.