运行外部应用程序不带扩展名为.exe [英] Run external application with no .exe extension

查看:655
本文介绍了运行外部应用程序不带扩展名为.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何运行在C# System.Diagnostics.Process.Start(executableName)外部应用; 但如果我要运行的应用程序扩展名是不能被Windows识别为扩展名的可执行文件。在我的情况下,它是 application.bin

I know how to run an external application in C# System.Diagnostics.Process.Start(executableName); but what if the application I want to run has extension that is not recognizable by Windows as extension of an executable. In my case it is application.bin.

问候。

推荐答案

关键是设置<一个href="http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.useshellexecute.aspx"相对=nofollow> Process.StartInfo.UseShellExecute 属性之前,要启动的过程中,例如:

Key is to set the Process.StartInfo.UseShellExecute property to false prior to starting the process, e.g.:

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"c:\tmp\test.bin";
p.StartInfo.UseShellExecute  = false;
p.Start();

这将直接启动程序。而不是去通过让我们尝试找出可执行文件指定的文件扩展名贝逻辑,该文件将被认为是可执行文件本身

This will start the process directly: instead of going through the "let's try to figure out the executable for the specified file extension" shell logic, the file will be considered to be executable itself.

另一个语法来实现相同的结果可能是:

Another syntax to achieve the same result might be:

var processStartInfo = new ProcessStartInfo
{
    FileName = @"c:\tmp\test.bin",
    UseShellExecute = false
};
Process.Start(processStartInfo);

这篇关于运行外部应用程序不带扩展名为.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆