Kill Process
Kills a process by name or PID
Common Properties
- Name - The custom name of the node.
- Version - The version of the node.
- Color - The custom color of the node.
- Icon - The icon for the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.
Input
- Process Name (Regex) - The name of the process to kill. Use Regular Expression syntax for wildcards. Only processes with names that match the pattern will be killed.
- Process ID - The PID of the process to kill.
You must provide either the Process Name (Regex) or the Process ID as input.
How It Works
The Kill Process node terminates running processes using two different methods:
-
By Process ID (PID):
- If a PID is provided, the node directly terminates that specific process
- Creates a process handle using the PID
- Sends a kill signal to terminate the process immediately
-
By Process Name:
- If only a process name is provided, the node searches all running processes
- Matches the executable path against the provided pattern (supports both exact match and regex)
- Terminates the first matching process found
- On Windows: Uses Terminate() method
- On Linux/macOS: Uses Kill() method for immediate termination
Requirements
- Process Identifier: Either Process Name (Regex) or Process ID must be provided (not both required)
- Permissions: May require elevated permissions to kill system processes or processes owned by other users
- Operating System: Works on Windows, Linux, and macOS with platform-specific termination methods
Error Handling
| Error Code | Description | Solution |
|---|---|---|
Core.Application.KillProcess.ErrOnCreate | Configuration parsing failed during node creation | Check node configuration in the flow |
Core.Application.KillProcess.ErrOnMessage | Message parsing error | Verify message format is valid JSON |
Core.Application.KillProcess.ErrNamePid | Both process name and PID are empty | Provide either a process name or PID |
Core.Application.KillProcess.ErrPid | Failed to create process handle or terminate process | Check if PID exists and you have permissions to kill it |
Core.Application.KillProcess.OutputMarshal | Failed to serialize output | Check output variable configuration |
Usage Examples
Example 1: Kill Process by PID
// Terminate a specific process by its ID
msg.processId = 1234;
// After node execution:
// Process with PID 1234 is terminated
Example 2: Kill Process by Exact Name
// Terminate a process by exact name match
msg.processName = "notepad.exe";
// After node execution:
// First process matching "notepad.exe" is terminated
Example 3: Kill Process by Regex Pattern
// Use regex to kill Chrome browser processes
msg.processName = ".*chrome.*";
// After node execution:
// First process matching the Chrome pattern is killed
// Note: Only kills ONE matching process
Usage Notes
- Priority: If both Process Name and PID are provided, the PID takes precedence
- Single Termination: When using process name, only the FIRST matching process is killed
- Platform Differences:
- Windows uses Terminate() method
- Linux/macOS uses Kill() method (more forceful)
- No Confirmation: Process termination is immediate with no confirmation dialog
- Graceful Shutdown: Processes are not given time to clean up; use with caution
- Pattern Matching: The node checks both exact string match and regex pattern match
- Error on Non-Existent: If PID doesn't exist, an error is thrown
Tips
- To kill multiple processes, use Get Processes first to get all PIDs, then loop with Kill Process
- Always use specific process names or PIDs to avoid accidentally killing wrong processes
- Test regex patterns carefully to ensure they match only intended processes
- Consider using Continue On Error if the process might not always be running
- On Windows, some system processes cannot be killed even with admin privileges
- Check process ownership before attempting to kill - may need elevated permissions
- Use Get Processes node first to verify the process exists before attempting to kill
Related Nodes
- Get Processes - Find process PIDs and names before killing
- Start Process - Launch processes that might need to be terminated later
- Loop - Kill multiple processes found by Get Processes
- Try-Catch - Handle errors when process doesn't exist or cannot be killed