向 PowerShell 进程发送中断信号

时间:2021-07-01 05:21:11

标签: vb.net process

我有一个 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 发送中断信号的方法。

有什么想法吗?

0 个答案:

没有答案
相关问题