向 PowerShell 进程发送中断信号

问题描述

我有一个 VB.NET 程序,它基本上“包装”了 PowerShell 以运行另一个名为 FFmpeg 的应用程序。所以,我的 VB.NET 应用程序运行 PowerShell,它运行 FFmpeg。出于性能原因,我必须这样做。

这是我用于启动 PowerShell 进程和运行 FFmpeg 命令的代码

'Start Powershell
Dim PSProc as Process = New Process()
With PSProc.StartInfo
    .FileName = "powershell"
    .UseShellExecute = False
    .CreateNowindow = True
    .RedirectStandardOutput = True
    .RedirectStandardError = True
    .RedirectStandardInput = True
End With
PSProc.Start()

'Run an FFmpeg command
PSProc.StandardInput.WriteLine("ffmpeg.exe ...")

无论如何,我正在努力想办法立即从我的应用程序中杀死 FFmpeg。

我尝试使用 PSProc.Kill(),但这会阻止执行,直到 FFmpeg 完成运行,我真的需要能够立即终止它。

当我从一个普通的 PowerShell 实例运行 FFmpeg 时,Ctrl+C(中断信号)会按照我想要的方式立即终止它。但是,我似乎无法找到从 VB 发送中断信号的方法

有什么想法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)