-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(forcekill): Support killing running applications and services #6603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MetalDevOps
wants to merge
14
commits into
ScoopInstaller:develop
Choose a base branch
from
MetalDevOps:feature/forcekill
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d6160f6
feat(forcekill): Support killing running applications and services be…
ddd0226
chore: Add changelog entry for forcekill
fcc9f62
chore(CHANGELOG): Fix formatting and scope label for forcekill entry
d8d1e31
fix(scoop-forcekill): Validate services, fix getopt and exitcode
af42cae
refactor(forcekill): Extract check_running_process and path rebasing
33b4788
Merge branch 'develop' of https://github.com/ScoopInstaller/Scoop int…
4f6513e
fix(forcekill): Adress PR feedback regarding properties and processdir
50c17de
fix(forcekill): implement WQL escaping, restart logic for reset, guar…
de82dfd
fix(forcekill): restrict automatic restarts to background tray apps; …
702d236
test(forcekill): add pester unit tests for check_running_process and …
e750951
feat: Add core scripts for install, uninstall, update, and reset, inc…
db19932
feat(forcekill): enhance process tracking and management with new fun…
2ebb3ab
feat(forcekill): add Get-SafeProcessPath function and enhance Get-Loc…
6921587
test(forcekill): enhance check_running_process and stop_running_proce…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # Usage: scoop forcekill <apps> | ||
| # Summary: Force close apps before updating | ||
| # Help: To mark a user-scoped app to force close: | ||
| # scoop forcekill <app> | ||
| # | ||
| # To mark a global app to force close: | ||
| # scoop forcekill -g <app> | ||
| # | ||
| # To explicitly define services to stop: | ||
| # scoop forcekill <app> --service <servicename> | ||
| # | ||
| # Options: | ||
| # -g, --global Force close globally installed apps | ||
| # -s, --service Services to stop (comma separated) | ||
|
|
||
| . "$PSScriptRoot\..\lib\getopt.ps1" | ||
| . "$PSScriptRoot\..\lib\json.ps1" | ||
| . "$PSScriptRoot\..\lib\manifest.ps1" | ||
| . "$PSScriptRoot\..\lib\versions.ps1" | ||
| . "$PSScriptRoot\..\lib\core.ps1" | ||
| . "$PSScriptRoot\..\lib\install.ps1" | ||
|
|
||
| $opt, $apps, $err = getopt $args 'gs:' 'global', 'service=' | ||
| if ($err) { "scoop forcekill: $err"; exit 1 } | ||
|
|
||
| $exitcode = 0 | ||
|
|
||
| $global = $opt.g -or $opt.global | ||
|
|
||
| if (!$apps) { | ||
| my_usage | ||
| exit 1 | ||
| } | ||
|
|
||
| if ($global -and !(is_admin)) { | ||
| error 'You need admin rights to mark a global app for forcekill.' | ||
| exit 1 | ||
| } | ||
|
|
||
| foreach ($app in $apps) { | ||
| if (!(installed $app $global)) { | ||
| if ($global) { | ||
| error "'$app' is not installed globally." | ||
| } else { | ||
| error "'$app' is not installed." | ||
| } | ||
| $exitcode = 1 | ||
| continue | ||
| } | ||
|
|
||
| if (get_config NO_JUNCTION) { | ||
| $version = Select-CurrentVersion -App $app -Global:$global | ||
| } else { | ||
| $version = 'current' | ||
| } | ||
| $dir = versiondir $app $version $global | ||
| $json = install_info $app $version $global | ||
| if (!$json) { | ||
| error "Failed to configure forcekill for '$app'." | ||
| $exitcode = 1 | ||
| continue | ||
| } | ||
| $install = @{} | ||
| $json | Get-Member -MemberType Properties | ForEach-Object { $install.Add($_.Name, $json.($_.Name)) } | ||
|
|
||
| $install.forcekill = $true | ||
|
|
||
| if ($opt.service) { | ||
| $services = $opt.service -split ',' | ForEach-Object { $_.Trim() } | ||
| $valid_services = @() | ||
| foreach ($svc in $services) { | ||
| if (Get-Service -Name $svc -ErrorAction SilentlyContinue) { | ||
| $valid_services += $svc | ||
| } else { | ||
| warn "Could not find service '$svc'. Skipping." | ||
| $exitcode = 1 | ||
| } | ||
| } | ||
| if ($valid_services.Count -gt 0) { | ||
| $install.forcekill_services = @($valid_services | Select-Object -Unique) | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| save_install_info $install $dir | ||
| success "$app is now marked to force close on update." | ||
| } | ||
|
|
||
| exit $exitcode | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # Usage: scoop unforcekill <apps> | ||
| # Summary: Remove force close setting from an app | ||
| # Help: To unmark a user-scoped app: | ||
| # scoop unforcekill <app> | ||
| # | ||
| # To unmark a global app: | ||
| # scoop unforcekill -g <app> | ||
| # | ||
| # Options: | ||
| # -g, --global Unmark globally installed apps | ||
|
|
||
| . "$PSScriptRoot\..\lib\getopt.ps1" | ||
| . "$PSScriptRoot\..\lib\json.ps1" | ||
| . "$PSScriptRoot\..\lib\manifest.ps1" | ||
| . "$PSScriptRoot\..\lib\versions.ps1" | ||
| . "$PSScriptRoot\..\lib\core.ps1" | ||
| . "$PSScriptRoot\..\lib\install.ps1" | ||
|
|
||
| $opt, $apps, $err = getopt $args 'g' 'global' | ||
| if ($err) { "scoop unforcekill: $err"; exit 1 } | ||
|
|
||
| $global = $opt.g -or $opt.global | ||
|
|
||
| if (!$apps) { | ||
| my_usage | ||
| exit 1 | ||
| } | ||
|
|
||
| if ($global -and !(is_admin)) { | ||
| error 'You need admin rights to unmark a global app.' | ||
| exit 1 | ||
| } | ||
|
|
||
| foreach ($app in $apps) { | ||
| if (!(installed $app $global)) { | ||
| if ($global) { | ||
| error "'$app' is not installed globally." | ||
| } else { | ||
| error "'$app' is not installed." | ||
| } | ||
| continue | ||
| } | ||
|
|
||
| if (get_config NO_JUNCTION) { | ||
| $version = Select-CurrentVersion -App $app -Global:$global | ||
| } else { | ||
| $version = 'current' | ||
| } | ||
| $dir = versiondir $app $version $global | ||
| $json = install_info $app $version $global | ||
| if (!$json) { | ||
| error "Failed to unmark forcekill for '$app'." | ||
| continue | ||
| } | ||
| $install = @{} | ||
| $json | Get-Member -MemberType Properties | ForEach-Object { $install.Add($_.Name, $json.($_.Name)) } | ||
|
|
||
| if (!$install.forcekill -and !$install.forcekill_services) { | ||
| info "'$app' is not marked for forcekill." | ||
| continue | ||
| } | ||
| $install.Remove('forcekill') | ||
| $install.Remove('forcekill_services') | ||
| save_install_info $install $dir | ||
| success "$app is no longer marked to force close on update." | ||
| } | ||
|
|
||
| exit $exitcode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.