如何使用 PowerShell 安装 .MSI [英] How to install .MSI using PowerShell
问题描述
我对 PowerShell 非常陌生,在理解上有一些困难.
我想在 PowerShell 脚本中安装 .MSI
.
可以请解释我如何做到这一点或为我提供初学者级别的教程.
I am very new to PowerShell and have some difficulty with understanding.
I want to install an .MSI
inside PowerShell script.
Can please explain me how to do that or provide me beginners level tutorial.
$wiObject = New-Object -ComObject WindowsInstaller.Installer
?????
推荐答案
当尝试使用以下命令通过 PowerShell 静默安装 MSI 时:
When trying to silently install an MSI via PowerShell using this command:
Start-Process $webDeployInstallerFilePath -ArgumentList '/quiet' -Wait
我收到错误:
指定的可执行文件不是适用于此操作系统平台的有效应用程序.
The specified executable is not a valid application for this OS platform.
我改为使用 msiexec.exe
使用此命令执行 MSI,它按预期工作:
I instead switched to using msiexec.exe
to execute the MSI with this command, and it worked as expected:
$arguments = "/i `"$webDeployInstallerFilePath`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
希望其他人觉得这很有用.
Hopefully others find this useful.
这篇关于如何使用 PowerShell 安装 .MSI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!