Upgrate WindowsNotepad (Store)
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "notepad-upgrade.ps1"
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "notepad-upgrade.ps1"
$w = Get-ChildItem -Path (Join-Path -Path $env:ProgramFiles -ChildPath 'WindowsApps') -Filter winget.exe -Recurse -ErrorAction SilentlyContinue |
Where-Object { $_.Directory.Name -like 'Microsoft.DesktopAppInstaller*' } |
Sort-Object { [version]($_.Directory.Name -replace 'Microsoft.DesktopAppInstaller_([\d\.]+)_.*','$1') } -Descending |
Select-Object -First 1 -ExpandProperty FullName
if (-not $w) {
Write-Output "winget.exe not found on this host."
exit 1
}
& $w upgrade --id 9MSMLRH6LZF3 --source msstore --accept-package-agreements --accept-source-agreements --silent
$code = $LASTEXITCODE
switch ($code) {
0 { Write-Output "Upgraded successfully."; exit 0 }
-1978335189 { Write-Output "Already at latest version."; exit 0 }
-1978335215 { Write-Output "Notepad not installed —- skipped (UNVERIFIED code, confirm before prod).skipped."; exit 0 }
default { Write-Output "winget exited with code $code"; exit $code }
}