Jump to content

Force kill a process that hangs

Recommended Posts

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 post
Share on other sites

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 by JohnNash
Link to post
Share on other sites

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 post
Share on other sites
  • 2 years later...
6 hours ago, barresoft said:

         $command="taskkill /im yourExecutable.exe /f"


RunWait (@comspec & " /c TaskKill /PID " & $PID & " /F")

That will work all the times.  Tested for life !

Link to post
Share on other sites
  • Moderators

@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 post
Share on other sites
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By ur
      I have created below code to run the python file.
      #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=icon.ico #AutoIt3Wrapper_Outfile=RunTaskRun.Exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: Author: Uday Kiran Reddy(ur) Script Function: To log python data to a file. #ce ---------------------------------------------------------------------------- #include <MsgBoxConstants.au3> #include "C:\Automation\ISMBuild\Library.au3" #include "ProcessEx_AddedNewEntryForLogging.au3" #include "CheckChangeinCommit.au3" If not NoChangesRequired() Then SendMail("Changes are in commit of erwin-main Repo","Will intimate once binaries are copied to Installshield machine") $hProcessHandle = _Process_RunCommand($PROCESS_RUN, $PROCESS_COMMAND & "C:\Python27\python.exe C:\BuildServer\AutoBuildServer\TaskRun.py") ; Capture the Process Handle $iPID = @extended ; Note the PID $returncode = _Process_DebugLogRunCommand($hProcessHandle, $iPID) ; Display the results in real-time Logging("Completed with ReturnCode "&$returncode) Else SendMail("No Changes are not there in commit of erwin-main Repo","So no Binaries for today.If it is needed, please remove the text file from location: "& @TempDir&"\git_erwin_commit.txt") EndIf When I kill the autoit execution exe in the middle of execution, it is not terminating the python.exe launched from script.
      Can you suggest how to do this?
    • By TarwadaC4
      hi guys

      see this Simple GUI

      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 227, 106, 201, 125) GUICtrlCreateInput("", 48, 24, 129, 21) $Button1 = GUICtrlCreateButton("Close", 48, 56, 129, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd

      is that possible to put the Process name to put it under auto kill like

      While 1 ProcessClose("Anything.exe") Wend
      sorry about my english
  • Create New...