How can I kill a program that might not exist from Perl on Win32?

前端 未结 3 749
被撕碎了的回忆
被撕碎了的回忆 2021-01-15 06:40

I\'m looking for a way to make Perl kill all firefox.exe processes on Win32, and not give an error if no process exists. I\'m currently using:

system(\'taskk         


        
相关标签:
3条回答
  • 2021-01-15 06:42

    without calling taskkill, you can use Perl modules, eg Win32::Process::List, win32::Process::Kill

    See also perldoc -f kill

    0 讨论(0)
  • 2021-01-15 06:57

    If you want to suppress all output including errors, try this:

    system('taskkill /F /IM firefox.exe >nul 2>&1');
    

    You can see more information about command redirection and pipes here:

    http://ss64.com/nt/syntax-redirection.html

    0 讨论(0)
  • 2021-01-15 06:59
    `taskkill /F /IM firefox.exe 2>&1`
    
    0 讨论(0)
提交回复
热议问题