Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: add fallback kill commands for windows (#1429)

tribhuwan038091b12d1f
diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
index 44ee32b81..373639388 100644
--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs
+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
@@ -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")
@@ -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
}
}
diff --git a/screenpipe-server/src/pipe_manager.rs b/screenpipe-server/src/pipe_manager.rs
index 53e13ce8e..1db038c22 100644
--- a/screenpipe-server/src/pipe_manager.rs
+++ b/screenpipe-server/src/pipe_manager.rs
@@ -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 {