CatSauce01 Posted March 29, 2022 Posted March 29, 2022 I'm a complete noob so please be gentle. I would like to create a script that will close an app for me. When I open Task Manager I can see the app I wish to close under "Apps" and under "Background processes". I figured out that ProcessClose ( "process" ) will close a process under "Apps" and WinClose ( "title" [, "text"] ) will close a process under "Windows processes" but I can't find anything that will close a process under "Background processes". I've tried searching for this topic but ended up with very old out of date information that no longer works or badly titled topics that don't help (a lot of badly titled topics out there).
Developers Jos Posted March 29, 2022 Developers Posted March 29, 2022 ProcessClose() will try to kill any process with that name. Give us a real example with code that isn't working. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
ad777 Posted March 29, 2022 Posted March 29, 2022 (edited) @CatSauce01 Welcome to Autoit Forum ,all you need to do is following: if you want to close process by name use: ProcessClose("notepad.exe");name of the process is notepad followed by .exe if you want to close Win App use: WinClose('Untitled - Notepad');close win app by it's title if you want to close process by pid use: ProcessClose(6531);pid of the process is 6531 if you want to close Multi process by name use: ;Close Multi Process by Name Local $arr = ProcessList("notepad.exe") ; For $i = 1 To $arr[0][0] ProcessClose($arr[$i][1]);close process by Pid of Process name Next Edited March 29, 2022 by ad777 none
CatSauce01 Posted March 29, 2022 Author Posted March 29, 2022 19 minutes ago, Jos said: ProcessClose() will try to kill any process with that name. Give us a real example with code that isn't working. Jos It's working to an extent. ProcessClose("CatSauce.exe") will close it under "Apps" in Task Manager but wont close the CatSauce.exe process under "Background processes". I'm guessing ad777 is telling me to got to Details in Task Manager and find the pid for the CatSauce.exe process under "Background processes".
Developers Jos Posted March 29, 2022 Developers Posted March 29, 2022 Yes it will when you have the rights for it. You could always try #RequireAdmin at the top of the script to ensure it runs with elevated rights. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
CatSauce01 Posted March 29, 2022 Author Posted March 29, 2022 1 minute ago, Jos said: Yes it will when you have the rights for it. You could always try #RequireAdmin at the top of the script to ensure it runs with elevated rights. Really? I checked CatSauce.exe security and it has full permission. I'll add #RequireAdmin just incase.
Developers Jos Posted March 29, 2022 Developers Posted March 29, 2022 I am talking about your script process whether it has enough rights to kill that CatSauce.exe process. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Nine Posted March 29, 2022 Posted March 29, 2022 (edited) You may also try this, if everything does not work : Local $iRet = RunWait ("TaskKill /IM CatSauce.exe /F", "", @SW_HIDE) ConsoleWrite("$iRet = " & $iRet & @CRLF) with or without #RequireAdmin Edited March 29, 2022 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
CatSauce01 Posted March 29, 2022 Author Posted March 29, 2022 I've tried all your suggestions with #RequireAdmin included and I still can't close CatSauce background process. I still have to manually open Task Manager, find CatSauce under "Background processes" and end task there.
CatSauce01 Posted March 29, 2022 Author Posted March 29, 2022 3 hours ago, ad777 said: @CatSauce01 Welcome to Autoit Forum ,all you need to do is following: if you want to close process by name use: ProcessClose("notepad.exe");name of the process is notepad followed by .exe if you want to close Win App use: WinClose('Untitled - Notepad');close win app by it's title if you want to close process by pid use: ProcessClose(6531);pid of the process is 6531 if you want to close Multi process by name use: ;Close Multi Process by Name Local $arr = ProcessList("notepad.exe") ; For $i = 1 To $arr[0][0] ProcessClose($arr[$i][1]);close process by Pid of Process name Next 2 hours ago, Jos said: Yes it will when you have the rights for it. You could always try #RequireAdmin at the top of the script to ensure it runs with elevated rights. 1 hour ago, Nine said: You may also try this, if everything does not work : Local $iRet = RunWait ("TaskKill /IM CatSauce.exe /F", "", @SW_HIDE) ConsoleWrite("$iRet = " & $iRet & @CRLF) with or without #RequireAdmin I've tried all your suggestions with #RequireAdmin included and I still can't close CatSauce background process. I still have to manually open Task Manager, find CatSauce under "Background processes" and end task there.
Nine Posted March 29, 2022 Posted March 29, 2022 (edited) Can you screen capture the part where CatSauce.exe is running in background (from task manager) and post the image here. Also post the code you are using that do not work. Edited March 29, 2022 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
CatSauce01 Posted March 30, 2022 Author Posted March 30, 2022 3 hours ago, Nine said: Can you screen capture the part where CatSauce.exe is running in background (from task manager) and post the image here. Also post the code you are using that do not work. I finally figured it out and now it's working great. Made some rookie mistakes 🤦♂️ which I'm really embarrassed about. Thank you to everyone who kindly helped me out on this.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now