Skip to content

Commit

Permalink
Allow Choco with gsudo running (draft) #74
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo Grignoli authored and Gerardo Grignoli committed Jan 12, 2021
1 parent f1b8941 commit f6d154c
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions build/Chocolatey/gsudo/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,27 @@
return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)
}

if (Get-Process gsudo -ErrorAction SilentlyContinue) {
gsudo.exe -k
Start-Sleep -Milliseconds 500
if (Test-Path "$bin\gsudo.exe.previous") {
Remove-Item "$bin\gsudo.exe.previous" | Out-Null
}

if (Test-Path "$bin\gsudo.exe") {
if (Get-Process gsudo -ErrorAction SilentlyContinue) {
$ErrorActionPreference = "Stop"
Write-Output '##### Please close gsudo before installing. #####'
Write-Output '##### Or run in new window with "-n" to let gsudo exit: #####'
Write-Output ' gsudo -n cmd /k choco upgrade gsudo'

throw "Unable to install/uninstall if gsudo is running"
gsudo.exe -k
Start-Sleep -Milliseconds 500

if (Get-Process gsudo -ErrorAction SilentlyContinue) {
Rename-Item "$bin\gsudo.exe" "$bin\gsudo.exe.previous"

if(! ($?)) {
$ErrorActionPreference = "Stop"
Write-Output '##### Please close gsudo before installing. #####'
Write-Output '##### Or run in new window with "-n" to let gsudo exit: #####'
Write-Output ' gsudo -n cmd /k choco upgrade gsudo'

throw "Unable to install/uninstall if gsudo is running"
}
}
}
}

Expand Down

0 comments on commit f6d154c

Please sign in to comment.