Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run external application with no .exe extension

Tags:

c#

.net

process

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.

like image 730
kjagiello Avatar asked Aug 08 '10 15:08

kjagiello


People also ask

How do I run a program without exe?

Yes – simply entering the program's full filename usually works. (The .exe requirement only exists in the GUI shell.) (It might be that the file needs an extension, though – so if you can't get MyProgram to run, rename it to MyProgram. notexe or MyProgram.

Is EXE file same as application?

application is a manifest file containing details about the application to be deployed. Setup.exe is a setup launcher/bootstrapper provided by the framework. It reads manifest data in the clickonce source folder and effects the necessary changes on the clients machine to enable the app run.

What does Linux use instead of exe?

Binary executables in Linux usually use the ELF (Executable and Linkable Format) file format. These are Linux's equivalent to the PE (Portable Executable) format used in Windows or the MZ and NE formats used in DOS and early Windows versions, all of which used the EXE file extension.

Do document files have .exe extension?

.exe is a common filename extension denoting an executable file (the main execution point of a computer program) for Microsoft Windows.


1 Answers

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);
like image 67
mdb Avatar answered Sep 27 '22 16:09

mdb