PrintToVeraeTimeStamp/platform/windows/scripts/uninstall-printer.ps1

14 lines
1.1 KiB
PowerShell

# Remove Verae printers, port, autostart (elevated).
$ErrorActionPreference = "Continue"
$LogDir = Join-Path $env:ProgramData "Verae\logs"
New-Item -ItemType Directory -Force -Path $LogDir | Out-Null
Start-Transcript -Path (Join-Path $LogDir ("uninstall-" + (Get-Date -Format yyyyMMdd-HHmmss) + ".log")) -Force | Out-Null
Get-Process verae-printhelper -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Printer | Where-Object { $_.Name -like "Verae TimeStamp PDF*" } | ForEach-Object { Write-Host "Remove-Printer $($_.Name)"; Remove-Printer -Name $_.Name }
Start-Sleep 1
$port = Join-Path $env:ProgramData "Verae\spool\fallback\verae-job.pdf"
if (Get-PrinterPort -Name $port -ErrorAction SilentlyContinue) { Write-Host "Remove-PrinterPort $port"; Remove-PrinterPort -Name $port }
Unregister-ScheduledTask -TaskName "Verae Print Helper" -Confirm:$false -ErrorAction SilentlyContinue
Remove-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Run' -Name VeraePrintHelper -ErrorAction SilentlyContinue
Get-Printer | Format-Table Name,DriverName,PortName -AutoSize | Out-String | Write-Host
Stop-Transcript | Out-Null