来自 PHP exec 的 taskkill [英] taskkill from PHP exec

查看:24
本文介绍了来自 PHP exec 的 taskkill的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚尝试执行此操作:

I have just tried to execute this:

function kill_hr(){

    exec("taskkill /IM uper.exe", $output = array(), $return);

    print_r($output);

    echo "<br />".$return;

}

然而,输出是这样的,它不是很有用:

However, the output is this and its not very useful:

数组 ( ) 1

当进程不存在时:

数组 ( ) 128

我想弄清楚为什么当进程存在时它给我一个 1 - 这是权限问题吗?如果是这样,我该如何纠正?

I am trying to work out why it gives me a 1 when the process exists - is this a permissions problem? If so, how can I rectify this?

推荐答案

感谢大家的帮助 - 我终于设法用这个来终止进程:

Thank you all for your help - I finally managed to kill the process using this:

$output = shell_exec('taskkill /F /IM "uper.exe"');

我相信它也适用于 exec,但重要的是 /F 强制它!:)

I am sure it will work with exec as well, but the important part is the /F forcing it! :)

这篇关于来自 PHP exec 的 taskkill的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆