# Multikill
# pip install killallappsinfolder
Tested against Windows 10 / Python 3.11 / Anaconda
# ProcKiller
`ProcKiller` is a Python utility designed to identify and terminate processes running on a Windows machine based on specific executable files found within given directories. It utilizes the Windows API through the `ctypes` library to manage processes.
## Features
- **Executable Filtering:** Search for executable files within specified directories.
- **Process Mapping:** Map running processes to executables.
- **Process Termination:** Terminate processes based on matching executable files.
- **Customizable Termination Criteria:** Include options for sending different signals and handling child processes.
## Usage
To use `ProcKiller`, run the script from the command line with directories as arguments, followed by the interval (in seconds) for repeated execution. Here’s how to invoke it:
```bash
python prockiller.py "C:\path\to\first\directory" "C:\path\to\second\directory" 60
```
This will search for executables in the specified directories and terminate any matching running processes every 60 seconds.
## Components
### Main Functions
- **get_command_line(pid):** Retrieves the command line used to start a process.
- **get_all_executables(folder, exeendings, filter_function):** Searches for executable files in a specified folder.
- **get_procs_to_kill(allexefiles_onlyexe, allfullpath):** Identifies running processes that should be terminated.
- **kill_running_procs(allprocsdic, ...):** Terminates the processes identified for termination.
### Class Definition
- **ProcKiller:** A class to encapsulate the functionality of finding and killing processes.
### Command-Line Interface
- The script can be executed directly from the command line with specified parameters for directories and execution interval.
## Code Example
```python
pki = (
ProcKiller(
folders=(
r"C:\ProgramData\BlueStacks_nxt",
r"C:\Program Files\Oracle",
r"C:\Program Files\BlueStacks",
r"C:\Program Files\BlueStacks_nxt",
),
kill_timeout=2,
protect_myself=True, # important, protect_myselfis False, you might kill the whole python process you are in.
winkill_sigint_dll=True, # dll first
winkill_sigbreak_dll=True,
winkill_sigint=True, # exe from outside
winkill_sigbreak=True,
powershell_sigint=True,
powershell_sigbreak=True,
powershell_close=True,
multi_children_kill=False, # try to kill each child one by one
multi_children_always_ignore_pids=(0, 4), # ignore system processes
print_output=True,
taskkill_as_last_option=True, # this always works, but it is not gracefully anymore):
exeendings=(".com", ".exe"),
filter_function=lambda files: True,
)
.get_active_procs()
.kill_running_procs()
)
# Use it again to keep on killing
pki()
```
## Contributions
Contributions are welcome! If you find a bug or have suggestions for improvements, please open an issue or submit a pull request.
## License
Distributed under the MIT License. See `LICENSE` for more information.
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/killallappsinfolder",
"name": "killallappsinfolder",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "ctypes, windows",
"author": "Johannes Fischer",
"author_email": "aulasparticularesdealemaosp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/14/e5/364fffe1c93b888cf85efbef8d4f3ca1d748fc9da96b7b03eaffba069b05/killallappsinfolder-0.10.tar.gz",
"platform": null,
"description": "\r\n\r\n# Multikill \r\n\r\n# pip install killallappsinfolder\r\n\r\nTested against Windows 10 / Python 3.11 / Anaconda\r\n\r\n# ProcKiller\r\n\r\n`ProcKiller` is a Python utility designed to identify and terminate processes running on a Windows machine based on specific executable files found within given directories. It utilizes the Windows API through the `ctypes` library to manage processes.\r\n\r\n## Features\r\n\r\n- **Executable Filtering:** Search for executable files within specified directories.\r\n- **Process Mapping:** Map running processes to executables.\r\n- **Process Termination:** Terminate processes based on matching executable files.\r\n- **Customizable Termination Criteria:** Include options for sending different signals and handling child processes.\r\n\r\n## Usage\r\n\r\nTo use `ProcKiller`, run the script from the command line with directories as arguments, followed by the interval (in seconds) for repeated execution. Here\u2019s how to invoke it:\r\n\r\n```bash\r\npython prockiller.py \"C:\\path\\to\\first\\directory\" \"C:\\path\\to\\second\\directory\" 60\r\n```\r\n\r\nThis will search for executables in the specified directories and terminate any matching running processes every 60 seconds.\r\n\r\n## Components\r\n\r\n### Main Functions\r\n\r\n- **get_command_line(pid):** Retrieves the command line used to start a process.\r\n- **get_all_executables(folder, exeendings, filter_function):** Searches for executable files in a specified folder.\r\n- **get_procs_to_kill(allexefiles_onlyexe, allfullpath):** Identifies running processes that should be terminated.\r\n- **kill_running_procs(allprocsdic, ...):** Terminates the processes identified for termination.\r\n\r\n### Class Definition\r\n\r\n- **ProcKiller:** A class to encapsulate the functionality of finding and killing processes.\r\n\r\n### Command-Line Interface\r\n\r\n- The script can be executed directly from the command line with specified parameters for directories and execution interval.\r\n\r\n## Code Example\r\n\r\n```python\r\npki = (\r\nProcKiller(\r\n folders=(\r\n r\"C:\\ProgramData\\BlueStacks_nxt\",\r\n r\"C:\\Program Files\\Oracle\",\r\n r\"C:\\Program Files\\BlueStacks\",\r\n r\"C:\\Program Files\\BlueStacks_nxt\",\r\n ),\r\n kill_timeout=2,\r\n protect_myself=True, # important, protect_myselfis False, you might kill the whole python process you are in.\r\n winkill_sigint_dll=True, # dll first\r\n winkill_sigbreak_dll=True,\r\n winkill_sigint=True, # exe from outside\r\n winkill_sigbreak=True,\r\n powershell_sigint=True,\r\n powershell_sigbreak=True,\r\n powershell_close=True,\r\n multi_children_kill=False, # try to kill each child one by one\r\n multi_children_always_ignore_pids=(0, 4), # ignore system processes\r\n print_output=True,\r\n taskkill_as_last_option=True, # this always works, but it is not gracefully anymore):\r\n exeendings=(\".com\", \".exe\"),\r\n filter_function=lambda files: True,\r\n)\r\n.get_active_procs()\r\n.kill_running_procs()\r\n)\r\n# Use it again to keep on killing\r\npki()\r\n```\r\n\r\n## Contributions\r\n\r\nContributions are welcome! If you find a bug or have suggestions for improvements, please open an issue or submit a pull request.\r\n\r\n## License\r\n\r\nDistributed under the MIT License. See `LICENSE` for more information.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Kill procs",
"version": "0.10",
"project_urls": {
"Homepage": "https://github.com/hansalemaos/killallappsinfolder"
},
"split_keywords": [
"ctypes",
" windows"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "503e55371f0be0cef11aee9761de7bb085737004f5c5ce1b2b3ddf8a9206f528",
"md5": "a3299234ad9318459073d40dd90aead4",
"sha256": "82e00bcd245608855531f40516d67701db73a9fa0459d82c03008be9380581c8"
},
"downloads": -1,
"filename": "killallappsinfolder-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a3299234ad9318459073d40dd90aead4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10265,
"upload_time": "2024-04-25T00:28:32",
"upload_time_iso_8601": "2024-04-25T00:28:32.567318Z",
"url": "https://files.pythonhosted.org/packages/50/3e/55371f0be0cef11aee9761de7bb085737004f5c5ce1b2b3ddf8a9206f528/killallappsinfolder-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "14e5364fffe1c93b888cf85efbef8d4f3ca1d748fc9da96b7b03eaffba069b05",
"md5": "35cc1ffeb1cd412a74ebe504b04a37d8",
"sha256": "6dd699c5d12b0e4a64f54b3ebb1aa45c9a55279eeaf21dd0fcab6dad721107d1"
},
"downloads": -1,
"filename": "killallappsinfolder-0.10.tar.gz",
"has_sig": false,
"md5_digest": "35cc1ffeb1cd412a74ebe504b04a37d8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9412,
"upload_time": "2024-04-25T00:28:34",
"upload_time_iso_8601": "2024-04-25T00:28:34.449405Z",
"url": "https://files.pythonhosted.org/packages/14/e5/364fffe1c93b888cf85efbef8d4f3ca1d748fc9da96b7b03eaffba069b05/killallappsinfolder-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-25 00:28:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hansalemaos",
"github_project": "killallappsinfolder",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "killallappsinfolder"
}