Termination of Non-essential Processes Topic is solved
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Termination of Non-essential Processes
Does anyone know whether it is possible to terminate all currently running processes which are not essential to the system? (This includes the user’s applications and processes like Windows Compatibility Telemetry.)
I need this to be able to free the system’s resources instantly and improve performance.
I need this to be able to free the system’s resources instantly and improve performance.
Re: Termination of Non-essential Processes
WinGet can get you a list. You can then use Process to close whichever you like.
Or:
Use at your own risk!
Code: Select all
DetectHiddenWindows, On
WinGet, win, List
list =
Loop, %win% {
WinGet, proc, ProcessPath, % "ahk_id " win%A_Index%
list .= "`n" proc
}
list := SubStr(list, 2)
Sort, list, U
MsgBox, 64, Processes, %list%
Code: Select all
DetectHiddenWindows, On
WinGet, win, List
list =
Loop, %win% {
WinGet, proc, ProcessName, % "ahk_id " win%A_Index%
SplitPath, proc,,,, fnBare
list .= fnBare > "" ? "`n" fnBare : ""
}
list := SubStr(list, 2)
Sort, list, U
MsgBox, 64, Processes, %list%
For each, proc in StrSplit(list, "`n")
If proc not in AutoHotkey ; Adjust as needed
; Process, Close, %proc%.exe
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Termination of Non-essential Processes
Thank you. This is a convenient way to get a list of running processes. What is the purpose of the following lines in the second script?mikeyww wrote: ↑27 Sep 2021, 14:16WinGet can get you a list. You can then use Process to close whichever you like.
Or:Code: Select all
DetectHiddenWindows, On WinGet, win, List list = Loop, %win% { WinGet, proc, ProcessPath, % "ahk_id " win%A_Index% list .= "`n" proc } list := SubStr(list, 2) Sort, list, U MsgBox, 64, Processes, %list%
Use at your own risk!Code: Select all
DetectHiddenWindows, On WinGet, win, List list = Loop, %win% { WinGet, proc, ProcessName, % "ahk_id " win%A_Index% SplitPath, proc,,,, fnBare list .= fnBare > "" ? "`n" fnBare : "" } list := SubStr(list, 2) Sort, list, U MsgBox, 64, Processes, %list% For each, proc in StrSplit(list, "`n") If proc not in AutoHotkey ; Adjust as needed ; Process, Close, %proc%.exe
Code: Select all
For each, proc in StrSplit(list, "`n")
If proc not in AutoHotkey
Process, Close, %proc%.exe
Re: Termination of Non-essential Processes
If you want to close some processes, this is one way to achieve it. It loops through each process in the list. If the process is not one in a list of specified processes, then the process is closed.
If... in
If... in
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Termination of Non-essential Processes
I have replaced “AutoHotkey” with “list” in the given script according to your instruction. Will the script now work as intended?
Code: Select all
DetectHiddenWindows, On
WinGet, win, List
list =
Loop, %win% {
WinGet, proc, ProcessName, % "ahk_id " win%A_Index%
SplitPath, proc,,,, fnBare
list .= fnBare > "" ? "`n" fnBare : ""
}
list := SubStr(list, 2)
Sort, list, U
MsgBox, 64, Processes, %list%
For each proc in StrSplit(list, "`n")
If proc not in list
Process, Close, %proc%.exe
Re: Termination of Non-essential Processes Topic is solved
On line 13, I think you would want to name the specific processes that you want to exclude, instead of excluding none of them. The list of processes to exclude can be a literal comma-separated string (see documentation as noted), or a variable name flanked by %. Of course, the answer to "Will this work?" is,.... try it! (But I recommend fixing your script first.)
A starting point: close all of the programs that you normally run. Look in Windows Task Manager to see what is left. Make a list of those processes, separated by commas. You can use that as your exclusion list. This particular script omits the file extension in the list, and adds it back when it closes each process.
An alternative approach to exclusions is to determine whether each window is visible, and just close those. That is safer, because you might otherwise end up closing various services and Windows programs that might be important. The following provides an example of identifying visible windows.
viewtopic.php?p=415031#p415031
A starting point: close all of the programs that you normally run. Look in Windows Task Manager to see what is left. Make a list of those processes, separated by commas. You can use that as your exclusion list. This particular script omits the file extension in the list, and adds it back when it closes each process.
An alternative approach to exclusions is to determine whether each window is visible, and just close those. That is safer, because you might otherwise end up closing various services and Windows programs that might be important. The following provides an example of identifying visible windows.
viewtopic.php?p=415031#p415031
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: Termination of Non-essential Processes
Thank you. Ii is easy to make a list of unnecessary processes displayed in Task Manager and then terminate them with the use of AutoHotkey. I needed this in order to end unnecessary processes like Compatibility Telemetry which use system resources.mikeyww wrote: ↑29 Sep 2021, 10:16On line 13, I think you would want to name the specific processes that you want to exclude, instead of excluding none of them. The list of processes to exclude can be a literal comma-separated string (see documentation as noted), or a variable name flanked by %. Of course, the answer to "Will this work?" is,.... try it! (But I recommend fixing your script first.)
A starting point: close all of the programs that you normally run. Look in Windows Task Manager to see what is left. Make a list of those processes, separated by commas. You can use that as your exclusion list. This particular script omits the file extension in the list, and adds it back when it closes each process.
An alternative approach to exclusions is to determine whether each window is visible, and just close those. That is safer, because you might otherwise end up closing various services and Windows programs that might be important. The following provides an example of identifying visible windows.
viewtopic.php?p=415031#p415031