Question

I'm having trouble creating a small AutoHotkey script to end all vsjitdebugger.exe processes on a test server. Here's 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 run the script tells me that the (vsjitdebugger.exe) process exists, as I would expect, but when WaitClose happens it still tells me that process(es) exist, and when I look in the Task Manager the same amount of vsjitdebugger.exe processes are still running.

I am able to end the vsjitdebugger.exe processes manually using Task Manager.

Basically I am unable to end these processes. Could anyone help me with this? Thanks.

Update: I've also tried this simple loop too, but with 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
    }   
}
Was it helpful?

Solution

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

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

OTHER TIPS

I do not have Microsoft Visual Studio installed on my computer, so I could not test 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 am not sure if this may be the cause of the any of the issues, but the WaitClose command does not close the process, it only waits for the process to no longer exist.

I just upgraded to Windows 7 and found I had the same problem with not being able to close a process. What worked for me was running the program in XP compatibility mode.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top