Office Click-to-Run installs the binaries when an Office-bearing ppkg is selected (e.g. GCCH_Prod_SFLD_StdOffice-x86_*) but doesn't create desktop shortcuts - operators only see Office in the Start Menu's Microsoft 365 folder. This baseline script fills that gap. Self-detects Office by EXE existence at C:\\Program Files\\Microsoft Office\\root\\Office16\\ or the (x86) equivalent. No Office found = silent no-op, so it's safe to run on every PC type (Display kiosks, Wax/Trace, Keyence, etc.) without needing a per-type filter. Creates Excel.lnk / Word.lnk / PowerPoint.lnk in two places: - C:\\Users\\Public\\Desktop\\ - visible to all users immediately - C:\\Users\\Default\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\ - inherited by every NEW user profile created on the device (Azure AD operator logons after enrollment) Numbered 05- so it runs after 00-PreInstall and 04-NetworkAndWinRM in the Shopfloor baseline sequence. Idempotent - WScript.Shell's CreateShortcut overwrites existing .lnks each run. Outlook / OneNote / Access / Publisher intentionally not shortcutted (scope decision; can be added by extending the $officeApps array). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
79 lines
2.8 KiB
PowerShell
79 lines
2.8 KiB
PowerShell
# 05-OfficeShortcuts.ps1 - Public desktop + Default User Start Menu shortcuts for
|
|
# the core Office apps (Excel, Word, PowerPoint).
|
|
#
|
|
# Only runs if Office is actually installed - self-detects via EXE existence so it
|
|
# silently no-ops on PC types whose ppkg didn't include Office (Display kiosks,
|
|
# Wax/Trace, etc.). Office Click-to-Run installs the binaries but doesn't create
|
|
# desktop shortcuts; this script fills that gap.
|
|
#
|
|
# Shortcuts land in two places:
|
|
# - C:\Users\Public\Desktop\ - visible to all users immediately
|
|
# - C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\
|
|
# - inherited by every NEW user profile
|
|
# (Azure AD logons after the device is
|
|
# enrolled)
|
|
#
|
|
# Idempotent: overwrites existing .lnk files each run.
|
|
|
|
$officeApps = @(
|
|
@{ Exe = 'EXCEL.EXE'; Name = 'Excel' }
|
|
@{ Exe = 'WINWORD.EXE'; Name = 'Word' }
|
|
@{ Exe = 'POWERPNT.EXE'; Name = 'PowerPoint' }
|
|
)
|
|
|
|
# Office binary location depends on x86 vs x64 install. The standard ShopFloor
|
|
# Office ppkg is x86 (GCCH_Prod_SFLD_StdOffice-x86_*) so it lands under
|
|
# Program Files (x86), but we check both so the script works either way.
|
|
$officeRoot = $null
|
|
foreach ($base in @(
|
|
'C:\Program Files\Microsoft Office\root\Office16',
|
|
'C:\Program Files (x86)\Microsoft Office\root\Office16'
|
|
)) {
|
|
if (Test-Path (Join-Path $base 'EXCEL.EXE')) {
|
|
$officeRoot = $base
|
|
break
|
|
}
|
|
}
|
|
|
|
if (-not $officeRoot) {
|
|
Write-Host "No Office install detected - skipping shortcut creation."
|
|
exit 0
|
|
}
|
|
|
|
Write-Host "Office detected at: $officeRoot"
|
|
|
|
$publicDesktop = 'C:\Users\Public\Desktop'
|
|
$defaultStart = 'C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs'
|
|
|
|
if (-not (Test-Path $defaultStart)) {
|
|
New-Item -Path $defaultStart -ItemType Directory -Force | Out-Null
|
|
}
|
|
|
|
$shell = New-Object -ComObject WScript.Shell
|
|
|
|
foreach ($app in $officeApps) {
|
|
$exePath = Join-Path $officeRoot $app.Exe
|
|
if (-not (Test-Path $exePath)) {
|
|
Write-Warning "$($app.Name) EXE not found at $exePath - skipping."
|
|
continue
|
|
}
|
|
foreach ($dest in @($publicDesktop, $defaultStart)) {
|
|
$lnkPath = Join-Path $dest "$($app.Name).lnk"
|
|
try {
|
|
$sc = $shell.CreateShortcut($lnkPath)
|
|
$sc.TargetPath = $exePath
|
|
$sc.WorkingDirectory = $officeRoot
|
|
$sc.IconLocation = "$exePath,0"
|
|
$sc.Save()
|
|
Write-Host " $($app.Name) -> $lnkPath"
|
|
}
|
|
catch {
|
|
Write-Warning "Failed to create $lnkPath : $($_.Exception.Message)"
|
|
}
|
|
}
|
|
}
|
|
|
|
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($shell) | Out-Null
|
|
Write-Host "Office shortcuts created."
|
|
exit 0
|