Skip to content

Commit ce66610

Browse files
committed
simple-dnscrypt: Update uninstaller script logic
1 parent 663eed9 commit ce66610

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

bucket/simple-dnscrypt.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,17 @@
4444
"script": [
4545
"$path_regex = [regex]::Escape((Split-Path -Path $dir -Parent))",
4646
"Stop-Process -Name 'SimpleDnsCrypt' -Force -ErrorAction SilentlyContinue",
47-
"$service = Get-Service -Include '*dnscrypt-proxy*' -ErrorAction SilentlyContinue",
47+
"if ($PSVersionTable.PSVersion -lt [version]::new(6, 0)) {",
48+
" $name_filter = 'Name like ''%dnscrypt-proxy%'''",
49+
" $service = Get-CimInstance -ClassName Win32_Service -Filter $name_filter -ErrorAction SilentlyContinue |",
50+
" Select-Object -Property *, @{ Name = 'BinaryPathName'; Expression = { $_.PathName } }",
51+
"} else {",
52+
" $service = Get-Service -Name '*dnscrypt-proxy*' -ErrorAction SilentlyContinue",
53+
"}",
4854
"if ($null -eq $service -or $service.BinaryPathName -notmatch $path_regex) { return }",
4955
"if (-not (is_admin)) { abort \"`n[ERROR] $app requires admin rights to $cmd.\" }",
5056
"Stop-Service -Name $service.Name -Force -ErrorAction SilentlyContinue",
51-
"Stop-Process -Name $service.Name -Force -ErrorAction SilentlyContinue",
57+
"Stop-Process -Name 'dnscrypt-proxy' -Force -ErrorAction SilentlyContinue",
5258
"Start-Sleep -Milliseconds 1500",
5359
"if ($cmd -ne 'uninstall') { return }",
5460
"if ($PSVersionTable.PSVersion -lt [version]::new(6, 0)) {",

0 commit comments

Comments
 (0)