2025-02-24 10:28:52 +01:00

34 lines
1.5 KiB
PowerShell

function Test-PendingReboot {
if (Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -EA Ignore) { return $true }
if (Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -EA Ignore) { return $true }
if (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Name PendingFileRenameOperations -EA Ignore) { return $true }
try {
$util = [wmiclass]"\\.\root\ccm\clientsdk:CCM_ClientUtilities"
$status = $util.DetermineIfRebootPending()
if (($null -ne $status) -and $status.RebootPending) {
return $true
}
}
catch { }
return $false
}
$msiexec = Get-Process msiexec
if ($msiexec) {
Write-Error "MSI is Running"
exit 1
}
if (Test-PendingReboot){
Write-Error "MSI is restart pending"
exit 1
}
$parameters = @("scenario=install", "scenariosubtype=ARP","sourcetype=None","productstoremove=AccessRuntimeRetail.16_en-us_x-none","culture=en-us","version.16=16.0")
Start-Process -FilePath "C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe" -ArgumentList $parameters -Wait
$parameters = @("scenario=install", "scenariosubtype=ARP","sourcetype=None","productstoremove=AccessRuntimeRetail.16_fr-fr_x-none","culture=fr-fr","version.16=16.0")
Start-Process -FilePath "C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe" -ArgumentList $parameters -Wait
exit 0