JohnNash Posted September 30, 2016 Share Posted September 30, 2016 ProcessClose works for ending a program. But now and then the program I try to close hangs (it does NOT show Not responding title,it just hangs). In that case ProcessClose is not able to close it. But manually I could click the X. So any suggestions how to close it anyway.... (except for clicking the x). Link to comment Share on other sites More sharing options...
genius257 Posted September 30, 2016 Share Posted September 30, 2016 (edited) You could try _WinAPI_TerminateProcess? Edit: Maybe only if ProcessClose fails? Also what was the @error value on fail? Edited September 30, 2016 by genius257 My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser Link to comment Share on other sites More sharing options...
jguinch Posted September 30, 2016 Share Posted September 30, 2016 If you can manually close it with the X, maybe you can just use WinClose Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Aareon Posted October 1, 2016 Share Posted October 1, 2016 I agree with @jguinch. WinClose() is probably your best bet. In my experience, this function has no problem ending a hanging program. Link to comment Share on other sites More sharing options...
kylomas Posted October 1, 2016 Share Posted October 1, 2016 JohnNash, 7 hours ago, JohnNash said: But manually I could click the X. When you close the window does the process terminate? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnNash Posted October 1, 2016 Author Share Posted October 1, 2016 (edited) Thanks for the tips. Both winclose and the WINAPI terminateprocess can not do it. Indeed if I press the cross manually it will terminate. So weird. Should be easily fixable I would think. I am able to get the process handle, which I thought maybe did not work, but it does... WinKill also does not work... Edited October 1, 2016 by JohnNash Link to comment Share on other sites More sharing options...
kylomas Posted October 1, 2016 Share Posted October 1, 2016 JohnNash, Can you post a reproducer? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnNash Posted October 1, 2016 Author Share Posted October 1, 2016 How would I do that? I mean the most important part is the program being stuck I'd guess. What should I show? Link to comment Share on other sites More sharing options...
kylomas Posted October 1, 2016 Share Posted October 1, 2016 Post your code... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnNash Posted October 1, 2016 Author Share Posted October 1, 2016 Well i've tried WinKill("title of app") Winclose ("tile of app"), also by class _WinAPI_TerminateProcess ( $hProcess) by handle the code of the app that hangs I cannot provide since it is a closed source thing (not mine). btw I just noticed the class of the process is changed into Ghost when it hangs. Link to comment Share on other sites More sharing options...
JohnNash Posted October 1, 2016 Author Share Posted October 1, 2016 Ah my bad. I never actually ran processclose. That one works. I mixed up with winclose. So ProcessClose ("nameofexe.exe") seems to work. Sorry for the misunderstanding. Link to comment Share on other sites More sharing options...
barresoft Posted December 1, 2018 Share Posted December 1, 2018 $command="taskkill /im yourExecutable.exe /f" run($command) Link to comment Share on other sites More sharing options...
Nine Posted December 1, 2018 Share Posted December 1, 2018 6 hours ago, barresoft said: $command="taskkill /im yourExecutable.exe /f" run($command) or RunWait (@comspec & " /c TaskKill /PID " & $PID & " /F") That will work all the times. Tested for life ! cramaboule 1 “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 2, 2018 Moderators Share Posted December 2, 2018 @barresoft please don't resurrect old threads, especially when the OP stated he had an accepted solution. After more than two years it is doubtful he is still looking for responses. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts