windows - 无法终止 Perl 中的进程

标签 windows perl process exe

我写了一段代码来运行一个exe文件如下:

 #!/usr/local/bin/perl     
 use Cwd;                      
 $directory   = 'e:/USER/';
 chdir($directory) or die ; 
 system("Bnc25-Windows.exe -nw");

现在我想写另一个代码来阻止它。我写道:

 #!/usr/local/bin/perl     
 use Cwd;                      
 $directory   = 'e:/USER/';
 chdir($directory) or die ; 
 kill Bnc25-Windows.exe ; 

但它不起作用,我在任务管理器窗口中看到 exe 文件正在运行。 我真的不知道问题出在哪里。感谢您的帮助

最佳答案

您正在使用 Windows。 Windows 中没有kill 命令。您可以为此使用 taskkill

再次使用system函数。

system("taskkill /im Bnc25-Windows.exe /f");

关于windows - 无法终止 Perl 中的进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14089243/

相关文章:

perl - 如何判断另一个进程何时停止写入 Perl 中的文件?

json - 使用 Perl 编码复杂的 JSON 结构

linux - 接收信号时阻塞的系统调用会发生什么?

macos - 如何在 Mac 上启动新应用程序?

python - 如何以与 Windows 服务不同的用户身份运行进程

windows - 在 Windows 上使用 SonarQube 和备用 IP 地址会出现绑定(bind)错误

c++ - 在类中包装 Windows 句柄

perl - 我如何配置 Strawberry Perl 从 c :\strawberry? 以外的东西运行

java - 使用 Java 执行命令行程序时仅收到 null

java - 将打印到 Windows CMD 的所有内容存储在一个文件中