- Official Post
Here a small script to install Office 2024 GVLK with different checks during install
PowerShell
# Start the stopwatch at the very beginning
$Stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
# 1. Enforce PowerShell as Administrator
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Error "Please run this PowerShell script as an Administrator!"
Exit
}
# Dynamically determine the directory where this script is located
$CurrentDir = $PSScriptRoot
if ([string]::IsNullOrEmpty($CurrentDir)) { $CurrentDir = Get-Location }
Write-Host "=== Starting Office Installation from $CurrentDir ===" -ForegroundColor Cyan
# 2. Check if setup.exe exists
if (-not (Test-Path "$CurrentDir\setup.exe")) {
Write-Error "ERROR: setup.exe was not found in $CurrentDir!"
Exit
}
# 3. Check if configuration.xml exists
$ConfigFile = "$CurrentDir\configuration.xml"
if (-not (Test-Path $ConfigFile)) {
Write-Error "ERROR: configuration.xml was not found in $CurrentDir!"
Exit
}
# 4. Check if local Office installation source data exists
$DataFolder = "$CurrentDir\Office\Data"
if (-not (Test-Path $DataFolder)) {
Write-Error "ERROR: Local Office installation files are missing!"
Exit
}
# 5. Trigger the installation using the local setup.exe
Write-Host "Starting Office installation in the background..." -ForegroundColor Yellow
Write-Host "(This might take a few minutes. Do NOT close this window.)" -ForegroundColor DarkGray
$Process = Start-Process -FilePath "$CurrentDir\setup.exe" -ArgumentList "/configure `"$ConfigFile`"" -PassThru
# Give the system 5 seconds to fully spawn the installation window
Start-Sleep -Seconds 5
# Actively loop and wait ONLY for active installer engines
Write-Host "Monitoring background installer tasks..." -ForegroundColor DarkGray
while (Get-Process -Name "setup", "officeinstaller" -ErrorAction SilentlyContinue) {
Start-Sleep -Seconds 3
}
# Stop the stopwatch before printing the final banner
$Stopwatch.Stop()
$ElapsedTime = "{0:mm}m {0:ss}s" -f $Stopwatch.Elapsed
# 6. Evaluate the final result
$OfficeCheck1 = Test-Path "C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"
$OfficeCheck2 = Test-Path "C:\Program Files (x86)\Microsoft Office\root\Office16\WINWORD.EXE"
if ($OfficeCheck1 -or $OfficeCheck2) {
Write-Host ""
Write-Host "===================================================================" -ForegroundColor Green
Write-Host " SUCCESS: Office has been successfully installed!" -ForegroundColor Green
Write-Host " Total Execution Time: $ElapsedTime" -ForegroundColor Green
Write-Host "===================================================================" -ForegroundColor Green
} else {
Write-Host ""
Write-Host "===================================================================" -ForegroundColor Red
Write-Host " ERROR: The Office installation process finished, but Office apps" -ForegroundColor Red
Write-Host " could not be found on the system. Please check ODT logs." -ForegroundColor Red
Write-Host " Total Execution Time: $ElapsedTime" -ForegroundColor Red
Write-Host "===================================================================" -ForegroundColor Red
}
Display More
Here is the XML file used for the download and/or installation - name it configuration.xml