.net Can';t使用自动热键关闭某些进程

.net Can';t使用自动热键关闭某些进程,.net,autohotkey,.net,Autohotkey,我在创建小型自动热键脚本以结束测试服务器上的所有vsjitdebugger.exe进程时遇到问题。以下是我的代码: Process, Exist, vsjitdebugger.exe NewPID = %ErrorLevel% if NewPID = 0 { MsgBox Process doesnt exist } else { MsgBox Process exists } Process, WaitClose, vsjitdebugger.exe, 5 NewPID =

我在创建小型自动热键脚本以结束测试服务器上的所有vsjitdebugger.exe进程时遇到问题。以下是我的代码:

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
}
运行时,脚本会告诉我(vsjitdebugger.exe)进程存在,正如我所期望的,但当WaitClose发生时,它仍会告诉我进程存在,当我查看任务管理器时,同样数量的vsjitdugger.exe进程仍在运行

我可以使用任务管理器手动结束vsjitdebugger.exe进程

基本上我无法结束这些过程。有人能帮我吗?谢谢

更新:我也尝试过这个简单的循环,但没有效果:

Loop, 100
{
    Process, Close, vsjitdebugger.exe
}
更新2:我尝试了下面建议的代码,但它永远停留在循环中,没有进程被终止:

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

我的计算机上没有安装Microsoft Visual Studio,因此无法使用确切的过程进行测试。我改用notepad.exe。使用您发布的简单循环,我成功地关闭了10个记事本实例

以下代码在我的计算机(WinXP SP3)上运行,以关闭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

我不确定这是否是任何问题的原因,但WaitClose命令不会关闭进程,它只会等待进程不再存在。

假设您有一个带有taskkill.exe的系统(我知道Windows XP有,我相信之后的所有版本也有),您可以使用这一行:

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

我刚升级到Windows7,发现我也有同样的问题,无法关闭进程。对我有效的是在XP兼容模式下运行该程序。

很好。我想知道为什么Process,Close不起作用,但调用taskkill却起作用?这可能与强制终止进程或终止由它产生的进程树有关。这就是/F和/T标志的作用。在Windows 7上,我必须以管理员身份运行AutoHotkey才能使进程、关闭、iexplore.exe工作。在Windows 7上,我必须以管理员身份运行AutoHotkey才能关闭某些任务