Github CLI repo在其Windows最新版本中有一個 MSI 安裝程式。我一直在嘗試安裝的檔案是gh_2.10.1_windows_amd64.msi.
目標是能夠在多臺計算機上遠程安裝該程式,這意味著靜默和自主安裝是必要的。
我嘗試執行各種Powershell命令,例如以下
MsiExec.exe /i gh_2.10.1_windows_amd64.msi /qn /L*v "%WINDIR%\Temp\GitHubCLI-Install.log
或者
Start-Process msiexec.exe -Wait -ArgumentList '/i "C:\Users\myUser\Downloads\gh_2.10.1_windows_amd64.msi" /q /le "C:\Install.log"'
以及我從各種論壇和 Stackoverflow 帖子中嘗試的許多其他各種排列和選項。
當我嘗試靜默安裝它時,該命令執行并且似乎立即完成。但是,Github CLI沒有安裝。
如果我運行類似:
msiexec /i C:\Users\myUser\Downloads\gh_2.10.1_windows_amd64.msi
出現一個設定 GUI,我需要單擊它才能安裝。
如何通過安裝遠程部署和安裝此軟體Powershell?
我知道它也可以安裝choco,scoop等winget。但是,每個系統都不能保證與這些服務的網路連接。所以我需要打包 msi 并以這種方式在本地安裝,以便 100% 確定安裝在系統上完成。
編輯
它似乎Powershell以管理員身份運行,允許安裝安靜地進行,無需任何輸入。但這需要確認 UAC 提示。這對于遠程更新是不可能的。我能做些什么?
從答案之一運行以下代碼后:
# Check $LASTEXITCODE afterwards.
cmd /c 'MsiExec.exe /i gh_2.10.1_windows_amd64.msi /qn /L*v "%WINDIR%\Temp\GitHubCLI-Install.log'
安裝發生并產生了日志。但是,發生了錯誤。以下是日志中產生錯誤的區域的片段:
Property(S): PrimaryVolumeSpaceAvailable = 0
Property(S): PrimaryVolumeSpaceRequired = 0
Property(S): PrimaryVolumeSpaceRemaining = 0
Property(S): INSTALLLEVEL = 1
Property(S): SOURCEDIR = C:\Users\myUser\Downloads\
Property(S): SourcedirProduct = {6E9B412F-42F0-4819-BDFF-3BFE1A28F531}
Property(S): ProductToBeRegistered = 1
MSI (s) (A4:DC) [12:45:54:500]: Note: 1: 1708
MSI (s) (A4:DC) [12:45:54:500]: Note: 1: 2205 2: 3: Error
MSI (s) (A4:DC) [12:45:54:500]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1708
MSI (s) (A4:DC) [12:45:54:500]: Note: 1: 2205 2: 3: Error
MSI (s) (A4:DC) [12:45:54:500]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709
MSI (s) (A4:DC) [12:45:54:500]: Product: GitHub CLI -- Installation failed.
MSI (s) (A4:DC) [12:45:54:500]: Windows Installer installed the product. Product Name: GitHub CLI. Product Version: 2.10.1. Product Language: 1033. Manufacturer: GitHub, Inc.. Installation success or error status: 1603.
MSI (s) (A4:DC) [12:45:54:506]: Deferring clean up of packages/files, if any exist
MSI (s) (A4:DC) [12:45:54:506]: MainEngineThread is returning 1603
MSI (s) (A4:EC) [12:45:54:509]: RESTART MANAGER: Session closed.
MSI (s) (A4:EC) [12:45:54:509]: No System Restore sequence number for this installation.
=== Logging stopped: 2022-05-18 12:45:54 ===
MSI (s) (A4:EC) [12:45:54:512]: User policy value 'DisableRollback' is 0
MSI (s) (A4:EC) [12:45:54:512]: Machine policy value 'DisableRollback' is 0
MSI (s) (A4:EC) [12:45:54:512]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (s) (A4:EC) [12:45:54:512]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (A4:EC) [12:45:54:513]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (A4:EC) [12:45:54:513]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (88:D8) [12:45:54:515]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (88:D8) [12:45:54:517]: MainEngineThread is returning 1603
=== Verbose logging stopped: 2022-05-18 12:45:54 ===
根據下面的一些評論,我嘗試在不同的系統上運行上述命令,因為 1603 錯誤顯然可能與某個檔案夾有關。但是,在不同的系統上,它說我沒有足夠的權限。
MSI (s) (20:38) [16:48:34:696]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709
MSI (s) (20:38) [16:48:34:696]: Product: GitHub CLI -- Error 1925. You do not have sufficient privileges to complete this installation for all users of the machine. Log on as administrator and then retry this installation.
Error 1925. You do not have sufficient privileges to complete this installation for all users of the machine. Log on as administrator and then retry this installation.
uj5u.com熱心網友回復:
正如您所說,安靜(無人值守,無 UI)安裝需要從提升的會話中運行。
在 PowerShell遠程處理via的背景關系中,遠程會話自動且始終以提升運行 - 假設目標用戶是遠程計算機上組的成員。
Invoke-Command-ComputerNameBUILTIN\Administrators
因此,請嘗試以下操作(假設當前用戶是目標機器上的管理員):
Invoke-Command -Computer $computers -ScriptBlock {
# Use of cmd /c ensures *synchronous* execution
# (and also interprets %WINDIR% as intended).
cmd /c 'MsiExec.exe /i gh_2.10.1_windows_amd64.msi /qn /L*v "%WINDIR%\Temp\GitHubCLI-Install.log'
if ($LASTEXITCODE -ne 0) { throw "Installation failed with exit code $LASTEXITCODE." }
}
要在本地機器上運行安裝程式- 從提升的會話中 - 只需直接從上面的腳本塊運行命令,即:
# Must run WITH ELEVATION.
# Check $LASTEXITCODE afterwards.
cmd /c 'MsiExec.exe /i gh_2.10.1_windows_amd64.msi /qn /L*v "%WINDIR%\Temp\GitHubCLI-Install.log'
uj5u.com熱心網友回復:
或(作為管理員):
install-package gh_2.10.1_windows_amd64.msi
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/477616.html
標籤:视窗 电源外壳 github-cli
