Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everyone!

I have a application that I want to execute a .bin file when pressing a button.
Is there something similar to this? The .bin file is a executable with a PE header.

C#
Process.Start("Program.exe");

but as
C#
Process.Start("Program.bin");


Any help would be appreciated.
Posted
Updated 23-Dec-22 7:52am

I've also a alternative solution:
C#
[System.Runtime.InteropServices.DllImport("shell32.dll")]
public static extern bool ShellExecute(IntPtr hwnd, string operation, string file, string param,int showCmd);

void ExecuteBin()
{
     ShellExecute(IntPtr.Zero,null,"cmd","/c BinFile.bin",0);
}


What I do: I invoke the ShellExecute method and I run cmd /c BinFile.bin. The parameter showCmd is set to 0, what means the cmd is not showing.
 
Share this answer
 
Nvm, I have the solution now.

C#
Process p = new Process();
p.StartInfo.FileName = "Program.bin";
p.StartInfo.UseShellExecute = false;
p.Start();
 
Share this answer
 
v2
Comments
Thomas Daniels 30-Oct-12 14:34pm    
Yes! You're right! +5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900