-
-
Notifications
You must be signed in to change notification settings - Fork 253
everything-alpha: Check properly for the existence of the Everything service #2279
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,16 +35,46 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||
| "Set-Content \"$dir\\install-context.reg\" $reg_content -Encoding ASCII" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "pre_uninstall": [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "Stop-Process -Name 'everything' -Force -ErrorAction SilentlyContinue", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "if ($(Get-Service -Name Everything -ErrorAction SilentlyContinue).Status -ne 'Stopped') {", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " if (!(is_admin)) { error 'Admin rights are required to stop Everything service'; break }", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " Stop-Service -Name 'Everything' -Force -ErrorAction SilentlyContinue | Out-Null", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "$appPathPattern = (Split-Path $dir -Parent).Replace('\\', '\\\\')", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "$processes = Get-Process -Name 'everything' -ErrorAction SilentlyContinue", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " | Where-Object { $_.Path -match $appPathPattern }", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "info \"Found $($processes.Length) Everything process(es) to stop\"", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "foreach ($process in $processes) {", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "}", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "if ((Get-Service -Name Everything -ErrorAction SilentlyContinue) -and ($cmd -eq 'uninstall')) {", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " if (!(is_admin)) { error 'Admin rights are required to remove Everything service'; break }", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " sc.exe delete 'Everything'", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "$services = Get-Service -Name Everything* -ErrorAction SilentlyContinue", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " | Where-Object { $_.BinaryPathName -match $appPathPattern }", | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I can reproduce this issue on PowerShell 5. And the |
||||||||||||||||||||||||||||||||||||||||||||||||||
| "", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "if ($services.Length -gt 1) {", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " error 'Multiple Everything services found, this is likely a bug with this manifest.'", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " break", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "} elseif ($services.Length -eq 0) {", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " info 'No Everything service found, continuing with uninstall.'", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "} else {", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " $service = $services[0]", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " $serviceName = $service.Name", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " info \"Found Everything service: $serviceName\"", | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+47
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same pipeline continuation and array-handling issues in service detection. Lines 47-48 have the same broken pipeline continuation (pipe at start of new line). Lines 50, 53 use Wrap in Proposed fix- "$services = Get-Service -Name Everything* -ErrorAction SilentlyContinue",
- " | Where-Object { $_.BinaryPathName -match $appPathPattern }",
+ "$services = @(Get-Service -Name Everything* -ErrorAction SilentlyContinue |",
+ " Where-Object { $_.BinaryPathName -match $appPathPattern })",
"",
- "if ($services.Length -gt 1) {",
+ "if ($services.Count -gt 1) {",
"error 'Multiple Everything services found, this is likely a bug with this manifest.'",
"break",
- "} elseif ($services.Length -eq 0) {",
+ "} elseif ($services.Count -eq 0) {",
"info 'No Everything service found, continuing with uninstall.'",
"} else {",📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| "", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " if (!(is_admin)) {", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " error 'Administrator rights are required to manage Windows services'", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " break", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " }", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " if ($service.Status -ne 'Stopped') {", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " info 'Stopping service'", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " Stop-Service -Name $serviceName -Force | Out-Null", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " }", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " if ($cmd -eq 'uninstall') {", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " info 'Removing service'", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " sc.exe delete $serviceName", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| " }", | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+70
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quote Per issue Proposed fix- "sc.exe delete $serviceName",
+ "sc.exe delete `\"$serviceName`\"",🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| "}", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "if ($cmd -eq 'uninstall') { reg import \"$dir\\uninstall-context.reg\" }", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "Get-ChildItem \"$dir\\*\" -Include 'Bookmarks*.csv', 'Everything.lng', 'Everything*.db', 'Everything*.ini', 'Filters*.csv', 'Plugins*.ini', 'Run History*.csv', 'Search History*.csv', 'Session*.json', 'NO_ALPHA_INSTANCE', 'Omit Results.csv' | Copy-Item -Destination \"$persist_dir\" -ErrorAction SilentlyContinue -Force" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "bin": "Everything.exe", | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pipeline continuation will not work with
|at the start of a new line.In PowerShell, when the previous line is a complete statement (like an assignment), placing
|at the start of the next line does not continue the pipeline—it either causes a syntax error or operates on$null. The pipe must be at the end of the preceding line.Additionally,
$processes.Lengthis unreliable because PowerShell doesn't wrap single objects in an array;.Lengthon a singleProcessobject returns$nullor a string length, not1. Use@(...).Countto force array context.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents