Unable to close certain processes with AutoHotkey

I am having trouble generating a small AutoHotkey script to terminate all vsjitdebugger.exe processes on a test server. Here is the code I have:

Process, Exist, vsjitdebugger.exe
NewPID = %ErrorLevel%
if NewPID = 0
{
    MsgBox Process doesnt exist
}
else
{
    MsgBox Process exists
}


Process, WaitClose, vsjitdebugger.exe, 5
NewPID = %ErrorLevel%
if NewPID = 0
{
    MsgBox Process no longer exists
}
else
{
    MsgBox Process still exists
}

      

When I run the script, it tells me that the process (vsjitdebugger.exe) exists as I would expect, but when WaitClose happens, it still tells me that the process exists and when I look in the task manager, the vsjitdebugger.exe process is still running ...

I can end the vsjitdebugger.exe processes manually using the task manager.

Basically, I cannot finish these processes. Can anyone help me with this? Thank.

Update : I've tried this simple loop too, to no avail:

Loop, 100
{
    Process, Close, vsjitdebugger.exe
}

      

Update 2 . I tried the following code suggested below, but it just stays in the loop forever and no processes are killed:

Loop
{
    Process, Close, vsjitdebugger.exe
    Process, wait, vsjitdebugger.exe, 0.1             
    NewPID = %ErrorLevel%
    if NewPID = 0
    {
        break
    }   
}

      

+2


source to share


3 answers


Assuming you have a system with taskkill.exe (I know what Windows XP does, and I believe all versions after that too), you can use this line:



Run, %comspec% /c "taskkill /F /IM vsjitdebugger /T"

      

+2


source


I don't have Microsoft Visual Studio installed on my computer, so I was not able to check using the exact process. I used notepad.exe instead. Using the simple loop you posted I was able to successfully close 10 instances of notepad.

The following code worked on my computer (WinXP SP3) to close all instances of notepad.exe



Process, Exist, notepad.exe
NewPID = %ErrorLevel%
if NewPID = 0
{
    MsgBox, Process doesnt exist
}
else
{
    MsgBox, Process exists
}

Loop
{
    Process, Close, Notepad.exe
    Process, wait, Notepad.exe, 0.1     
    NewPID = %ErrorLevel%
    if NewPID = 0
    {
        break
    }   
}
Process, WaitClose, Notepad.exe
MsgBox, this works

      

I'm not sure if this might be the cause of any of the problems, but the WaitClose command does not close the process, it only waits for the process to no longer exist.

+3


source


I just upgraded to Windows 7 and found that I had the same problem that I was unable to close the process. The program worked for me in XP compatibility mode.

+1


source







All Articles