uninstall.ps1 1.0 KB

1234567891011121314151617181920212223242526272829
  1. $ErrorActionPreference = 'Stop'
  2. $appName = 'ComputerShopWpf'
  3. $displayName = 'Продажа компьютерной техники'
  4. $installDir = Join-Path $env:LOCALAPPDATA $appName
  5. $desktopPath = [Environment]::GetFolderPath('DesktopDirectory')
  6. $shortcutPath = Join-Path $desktopPath "$displayName.lnk"
  7. $uninstallShortcutPath = Join-Path $desktopPath "$displayName - удалить.lnk"
  8. if (Test-Path -LiteralPath $shortcutPath) {
  9. Remove-Item -LiteralPath $shortcutPath -Force
  10. }
  11. if (Test-Path -LiteralPath $uninstallShortcutPath) {
  12. Remove-Item -LiteralPath $uninstallShortcutPath -Force
  13. }
  14. if (Test-Path -LiteralPath $installDir) {
  15. $tempScript = Join-Path $env:TEMP 'ComputerShopWpf_remove.cmd'
  16. $command = "@echo off`r`ntimeout /t 1 /nobreak > nul`r`nrmdir /s /q `"$installDir`"`r`n"
  17. Set-Content -LiteralPath $tempScript -Value $command -Encoding Default
  18. Start-Process -FilePath $tempScript -WindowStyle Hidden
  19. }
  20. (New-Object -ComObject WScript.Shell).Popup("Приложение удалено.", 0, $displayName, 64) | Out-Null