Files
windows-unattend/steps/16-install-telegram.ps1
Timmy 8fdce82737 16-install-telegram 改用 winget machine-wide + 建 Public Desktop 捷徑
之前用 Telegram 官方 tsetup.exe 即使加 /ALLUSERS 也會 fallback 到 per-user
(PrivilegesRequired=lowest 寫死),裝到 Admin 的 AppData,User 帳號看不到。
改成:
- winget install --scope machine(用 portable 包,所有 user 都能用)
- 抓實際 Telegram.exe 路徑
- 在 C:\Users\Public\Desktop 建立 Telegram.lnk,User 一登入就看得到
2026-04-28 08:41:39 +08:00

34 lines
1.6 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
. "$PSScriptRoot\_common.ps1"
Section 'install-telegram' {
Wait-Network -timeoutSec 30
# Telegram 官方 tsetup.exe 是 Inno Setup PrivilegesRequired=lowest
# /VERYSILENT /ALLUSERS 都會 fallback per-user裝到 Admin 的 AppData
# 而 User 帳號看不到。改用 winget 的 portable 包 (--scope machine)
# 所有 user 都能用,並在 Public Desktop 放一個捷徑讓使用者看得到。
$winget = (Get-Command winget -ErrorAction SilentlyContinue).Source
if (-not $winget) { Log 'winget not found; skipping Telegram'; return }
& $winget install --id Telegram.TelegramDesktop -e --silent --source winget --scope machine `
--accept-source-agreements --accept-package-agreements 2>&1 |
ForEach-Object { Log " winget: $_" }
# 找實際 Telegram.exewinget portable 路徑包含版本字尾,動態找)
$exe = Get-ChildItem 'C:\Program Files\WinGet\Packages' -Recurse -Filter 'Telegram.exe' -EA SilentlyContinue |
Where-Object { $_.Length -gt 1MB } |
Select-Object -First 1 -ExpandProperty FullName
if (-not $exe) { Log 'Telegram.exe not found after winget install'; return }
Log "Telegram.exe: $exe"
# Public Desktop 捷徑C:\Users\Public\Desktop\Telegram.lnk
$lnkPath = Join-Path $env:PUBLIC 'Desktop\Telegram.lnk'
$shell = New-Object -ComObject WScript.Shell
$lnk = $shell.CreateShortcut($lnkPath)
$lnk.TargetPath = $exe
$lnk.WorkingDirectory = (Split-Path $exe -Parent)
$lnk.IconLocation = $exe
$lnk.Save()
Log "Created Public desktop shortcut: $lnkPath"
}