# 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