简体   繁体   English

Call to Process可与Debug一起正常使用,但在已安装的应用程序中不起作用

[英]Call to Process works fine with Debug, but it doesn't work in the installed application

I am developing a Windows Form program that has callings to ffmpeg library through the class Process . 我正在开发一个Windows Form程序,该程序具有通过Process类调用ffmpeg库的功能。

It works fine when I run it with the Debug in Visual Studio 2013. But when I install the program and I invoke the operation that call to the ffmpeg Process , it doesn't work. 当我在Visual Studio 2013中使用“调试”运行它时,它可以正常工作。但是,当我安装程序并调用调用ffmpeg Process ,它不起作用。 The cmd screen appears an disappears and nothing happens. cmd屏幕出现消失并且什么也没有发生。

I have tried to know what can be happening getting a log file with the output of ffmpeg , in case it was a problem in the ffmpeg libraries. 我试图知道用ffmpeg的输出获取日志文件会发生什么情况,以防ffmpeg库出现问题。 However, after executing it the log is empty, what means that the ffmpeg command has not been executed. 但是,执行该日志后,该日志为空,这意味着尚未执行ffmpeg命令。

Can someone help me, please? 有人能帮助我吗?

The code is this: 代码是这样的:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/c " + ffmpegPath + " " + commandArguments;
using (Process processTemp = new Process())
{
    processTemp.StartInfo = startInfo;
    processTemp.EnableRaisingEvents = true;
    processTemp.Start();
    processTemp.WaitForExit();
}

I am invoking to cmd.exe (not directly ffmpeg.exe ) because in the arguments sometimes there can be a pipe (that is why the command starts with " /c "). 我正在调用cmd.exe (不是直接ffmpeg.exe ),因为有时在参数中可能存在管道(这就是命令以“ /c ”开头的原因)。

Are you sure this isn't a privileges issue when trying to execute the cmd.exe (eg you need administrator privileges) 确定执行cmd.exe时,这不是特权问题吗(例如,您需要管理员特权)

try adding 尝试添加

startInfo.Verb = "runas";

Paul 保罗

Hmm its not a path issue with spaces in file/directory names is it? 嗯,不是文件/目录名称中有空格的路径问题吗? For ffmpegPath or one of your command parameters (if a file path). 对于ffmpegPath或您的命令参数之一(如果是文件路径)。 Surround all file paths with ' like below. 将所有文件路径都用'包围,如下所示。

Try surrounding any file paths with ' 尝试用'包围所有文件路径

 startInfo.Arguments = "/c '" + ffmpegPath + "' " + commandArguments;

Also you could try adding /K to the cmd command call to stop if from closing the command prompt when it finishes. 您也可以尝试将/ K添加到cmd命令调用中,以在完成时关闭命令提示符后停止。 It might tell you the error before it closes the window but you wont see it if it closes so quickly 它可能会在关闭窗口之前告诉您错误,但如果关闭如此迅速,您将看不到它

Good luck :) Paul 祝你好运:)保罗

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在调用process.start时StartInfo.stuff不起作用,但是Process.start在C#中可以正常工作 - Why StartInfo.stuff doesn't work when calling process.start but Process.start works fine in C# 具有数据库的C#应用​​程序工作正常,但部署后无法正常工作 - C# application with database works fine but after deploy doesn't work 设置语言在已安装的应用程序上不起作用 - Setting Language doesn't work on installed application 尽管过程正常,但为什么参数化查询不起作用 - Why parameterized query doesn't work although the procedure works fine 我的WebApi在Visual Studio上运行良好,但在IIS上不起作用 - My WebApi works fine on Visual Studio but doesn't work on IIS Aero Glass在Windows 7上可以正常工作,但在Vista上则不能工作 - Aero Glass works fine on Windows 7, but doesn't work on Vista HttpClient PostAsync() 不起作用,而 POSTMAN 工作正常 - HttpClient PostAsync() doesn't work while POSTMAN works fine Visual Studio 2015 Debug在多线程应用程序中不起作用 - Visual Studio 2015 Debug doesn't work in multithread application ZeroMQ 在 Unity 中不起作用,但可以作为控制台应用程序使用 - ZeroMQ doesn't work in Unity, but works as console application EF6延迟加载不起作用,而快速加载可以正常工作 - EF6 lazy loading doesn't work while eager loading works fine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM