17 lines
1.1 KiB
PowerShell
17 lines
1.1 KiB
PowerShell
[CmdletBinding()]
|
|
param([switch]$RemoveData, [switch]$Silent)
|
|
$ErrorActionPreference = 'Stop'
|
|
$installRoot = [IO.Path]::GetFullPath((Join-Path $env:ProgramFiles 'QVPN'))
|
|
$setup = Join-Path $installRoot 'QVPN-Setup.exe'
|
|
if (-not (Test-Path -LiteralPath $setup -PathType Leaf)) { throw 'QVPN installer was not found in Program Files.' }
|
|
if ((Get-Item -LiteralPath $installRoot -Force).Attributes -band [IO.FileAttributes]::ReparsePoint) { throw 'The QVPN directory is a reparse point.' }
|
|
$arguments = @('--uninstall')
|
|
if ($RemoveData) { $arguments += '--remove-data' }
|
|
if ($Silent) { $arguments += '--silent' }
|
|
$process = Start-Process -FilePath $setup -ArgumentList $arguments -Verb RunAs -WindowStyle Hidden -PassThru -Wait
|
|
if ($process.ExitCode -ne 0) { throw "QVPN uninstaller exited with code $($process.ExitCode). Check the setup log in your TEMP folder." }
|
|
$deadline = [DateTime]::UtcNow.AddSeconds(90)
|
|
while ((Test-Path -LiteralPath $installRoot) -and [DateTime]::UtcNow -lt $deadline) { Start-Sleep -Milliseconds 500 }
|
|
if (Test-Path -LiteralPath $installRoot) { throw 'Removal did not finish. Check QVPN-Setup-*.log in your TEMP folder.' }
|
|
Write-Host 'QVPN removed.'
|