在 PowerShell 中安裝 MSI 檔案

Migel Hewage Nimesha 2023年1月30日 2022年5月16日
  1. 在 PowerShell 中安裝 MSI 檔案
  2. 在 PowerShell 中通過呼叫路徑和檔案來呼叫 .msi 檔案
在 PowerShell 中安裝 MSI 檔案

PowerShell 是一種 Microsoft 工具,可用於 Windows、Linux 和 Mac 使用者的指令碼編寫。不同的運算子有不同版本的 PowerShell。

對於 Windows 使用者,在 Windows XP 以上的 Windows 作業系統中,預設安裝 PowerShell。但是,如果需要,其他使用者可以從 Microsoft 站點下載適用於 PowerShell 的應用程式。

專業人員可以通過使用 PowerShell 工具來實現高階指令碼編寫目的。這些可以用作自動化工具和基於 CI\CD 的系統的配置管理。

在 PowerShell 中安裝 MSI 檔案

本文將討論使用 PowerShell 應用程式指令碼平臺安裝其他應用程式。PowerShell 支援不同的作業系統用途,包括通過呼叫檔案和函式作為跨平臺應用程式來安裝 .exe 和其他類似應用程式。

MSI 是 Windows 的一種 Microsoft 安裝包檔案格式,源自 Microsoft Installer。與 .exe 檔案格式類似,.msi 是用於安裝儲存和解除安裝程式的支援檔案型別。

.exe 檔案類似,.msi 檔案也可以通過 PowerShell 執行。使用者可以在 PowerShell 指令碼中使用幾種不同的方法輕鬆安裝 .msi 檔案。

在 PowerShell 中通過呼叫路徑和檔案來呼叫 .msi 檔案

實現此要求的最簡單方法是直接通過 PowerShell 指令碼呼叫檔案。以下是用於上述目的的程式碼。

Start-Process FirefoxSetup14.0.1.msi

以下是執行的螢幕截圖,輸出為 Firefox 的 .msi 檔案用於安裝。

powershell 安裝 msi

還有其他方法,如 msiexecinstall-package 等。這些方法可用於安裝或 .msi 執行過程。

Migel Hewage Nimesha avatar Migel Hewage Nimesha avatar

Nimesha is a Full-stack Software Engineer for more than five years, he loves technology, as technology has the power to solve our many problems within just a minute. He have been contributing to various projects over the last 5+ years and working with almost all the so-called 03 tiers(DB, M-Tier, and Client). Recently, he has started working with DevOps technologies such as Azure administration, Kubernetes, Terraform automation, and Bash scripting as well.