JohnNash

Force kill a process that hangs

11 posts in this topic

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).

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You could try _WinAPI_TerminateProcess? :)

Edit:

Maybe only if ProcessClose fails?

Also what was the @error value on fail?

Edited by genius257

Share this post


Link to post
Share on other sites

#4 ·  Posted

I agree with @jguinch. WinClose() is probably your best bet. In my experience, this function has no problem ending a hanging program.

Share this post


Link to post
Share on other sites

#5 ·  Posted

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by JohnNash

Share this post


Link to post
Share on other sites

#7 ·  Posted

JohnNash,

Can you post a reproducer?

kylomas


Forum Rules         Procedure for posting code

Share this post


Link to post
Share on other sites

#8 ·  Posted

How would I do that? I mean the most important part is the program being stuck I'd guess. What should I show?

Share this post


Link to post
Share on other sites

#10 ·  Posted

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. 

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

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. 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • TarwadaC4
      put the Process name to Auto Kill [ in GUI ]
      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