Skip to content

Commit

Permalink
fix: add fallback kill commands for windows (#1429)
Browse files Browse the repository at this point in the history
* fix: add fallback kill commands for windows

* fix: commnand (missing *)

---------

Co-authored-by: tribhuwan-kumar <[email protected]>
  • Loading branch information
tribhuwan-kumar and tribhuwan-kumar authored Feb 20, 2025
1 parent 5d22639 commit 038091b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
15 changes: 14 additions & 1 deletion screenpipe-app-tauri/src-tauri/src/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub async fn stop_screenpipe(
{
const CREATE_NO_WINDOW: u32 = 0x08000000;
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
tokio::process::Command::new("powershell")
let _ = tokio::process::Command::new("powershell")
.arg("-NoProfile")
.arg("-WindowStyle")
.arg("hidden")
Expand All @@ -117,6 +117,19 @@ pub async fn stop_screenpipe(
))
.creation_flags(CREATE_NO_WINDOW)
.output()
.await;

// fallback wild kill
tokio::process::Command::new("powershell")
.arg("-NoProfile")
.arg("-WindowStyle")
.arg("hidden")
.arg("-Command")
.arg(format!(
r#"Get-WmiObject Win32_Process | Where-Object {{ $_.CommandLine -like "*screenpipe*" }} | ForEach-Object {{ taskkill.exe /T /F /PID $_.ProcessId }}"#,
))
.creation_flags(CREATE_NO_WINDOW)
.output()
.await
}
}
Expand Down
18 changes: 18 additions & 0 deletions screenpipe-server/src/pipe_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,24 @@ impl PipeManager {
.await;
}

#[cfg(windows)]
{
// killing by name is faster
const CREATE_NO_WINDOW: u32 = 0x08000000;
let _ = tokio::process::Command::new("powershell")
.arg("-NoProfile")
.arg("-WindowStyle")
.arg("hidden")
.arg("-Command")
.arg(format!(
r#"Get-WmiObject Win32_Process | Where-Object {{ $_.CommandLine -like "*.screenpipe\pipes\{}*" }} | ForEach-Object {{ taskkill.exe /T /F /PID $_.ProcessId }}"#,
&id.to_string()
))
.creation_flags(CREATE_NO_WINDOW)
.output()
.await;
}

match handle.state {
PipeState::Port(port) => {
tokio::task::spawn(async move {
Expand Down

0 comments on commit 038091b

Please sign in to comment.