Three final optimization batches: 1. Start-Transcript added to 4 scripts that lacked standalone logging: 04-NetworkAndWinRM.ps1, 05-OfficeShortcuts.ps1, 01-eDNC.ps1, 02-MachineNumberACLs.ps1. Each writes to C:\Logs\SFLD\<name>.log with append mode. Stop-Transcript added before exit points. 2. preinstall.json: Oracle Client PCTypes changed from ["*"] to ["Standard", "CMM", "Genspect", "Keyence", "WaxAndTrace", "Display"]. Lab Workstations don't need Oracle Client (shopfloor data app dependency). VC++ redists stay at ["*"] (harmless shared deps). 3. Edge profiles added to all remaining PC types in site-config.json: CMM, Genspect, Keyence, WaxAndTrace, Standard-Timeclock all get the standard 3-tab setup (Plant Apps + Homepage + Dashboard) with homepage = tsgwp00524. Display-Lobby and Display-Dashboard get Shopfloor Dashboard as both homepage and single tab. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
102 lines
3.9 KiB
PowerShell
102 lines
3.9 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.
|
|
|
|
# --- Transcript ---
|
|
$logDir = 'C:\Logs\SFLD'
|
|
if (-not (Test-Path $logDir)) { try { New-Item -ItemType Directory -Path $logDir -Force | Out-Null } catch {} }
|
|
try { Start-Transcript -Path (Join-Path $logDir '05-OfficeShortcuts.log') -Append -Force | Out-Null } catch {}
|
|
|
|
$officeApps = @(
|
|
@{ Exe = 'EXCEL.EXE'; Name = 'Excel' }
|
|
@{ Exe = 'WINWORD.EXE'; Name = 'Word' }
|
|
@{ Exe = 'POWERPNT.EXE'; Name = 'PowerPoint' }
|
|
)
|
|
|
|
# Office binary location varies by install type and version:
|
|
# - Office 2019+ / M365 / LTSC Click-to-Run: <PF>\Microsoft Office\root\Office16\
|
|
# - Office 2016 MSI (legacy): <PF>\Microsoft Office\Office16\ (no root\)
|
|
# - Office 2013 MSI: <PF>\Microsoft Office\Office15\
|
|
# - x86 Office on 64-bit Windows: Program Files (x86)\...
|
|
# The standard ShopFloor Office ppkg is x86 Click-to-Run so normal case
|
|
# is "Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE", but
|
|
# we check all variants so the script works across SKUs.
|
|
$officeSearchRoots = @(
|
|
'C:\Program Files\Microsoft Office\root\Office16',
|
|
'C:\Program Files (x86)\Microsoft Office\root\Office16',
|
|
'C:\Program Files\Microsoft Office\Office16',
|
|
'C:\Program Files (x86)\Microsoft Office\Office16',
|
|
'C:\Program Files\Microsoft Office\Office15',
|
|
'C:\Program Files (x86)\Microsoft Office\Office15'
|
|
)
|
|
|
|
$officeRoot = $null
|
|
foreach ($base in $officeSearchRoots) {
|
|
if (Test-Path (Join-Path $base 'EXCEL.EXE')) {
|
|
$officeRoot = $base
|
|
break
|
|
}
|
|
}
|
|
|
|
if (-not $officeRoot) {
|
|
Write-Host "No Office install detected - skipping shortcut creation."
|
|
Write-Host "Searched:"
|
|
foreach ($p in $officeSearchRoots) {
|
|
$hit = if (Test-Path $p) { "(dir exists)" } else { "(missing)" }
|
|
Write-Host " $p $hit"
|
|
}
|
|
try { Stop-Transcript | Out-Null } catch {}
|
|
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."
|
|
try { Stop-Transcript | Out-Null } catch {}
|
|
exit 0
|