views:

51

answers:

3

Currently I am using the below code to start my application (which is working):

ProcessStartInfo myApp = new ProcessStartInfo();
myApp.FileName = "cmd.exe";
myApp.Arguments = @"/K D:\dir\file.bin additional args to raise app";
myApp.WindowStyle = ProcessWindowStyle.Hidden;
myApp.CreateNoWindow = true;

try
{
    Process.Start(myApp);
}
catch (Exception ex)
{
    MessageBox.Show(ex.ToString());
}

But if possible I would like to call it directly, but since it is a .bin extension not recognized to any application (like txt is to notepad for example) Process.Start won't start it unless i use the cmd to call it.

What other way do I have to start my application directly without having to summon it from cmd ?

I can also start it with begin > run and start aswell:

start D:/my/path/file.bin additional args to raise app
+2  A: 

1) You do not have to provide full path of the cmd.exe. System will be able to find it

2) It seems you are trying to run cmd.exe with parameters in order to run your bin file. This will not work.

3) What is the bin file? You can assign a default application to .bin file type. Alternatively, start the aplication runner with ProcessStartInfo and pass your .bin file.

4) Not sure if all applications wil happliy use "/" instead of "\" .

Aliostad
2) works just fine, like i said above the first code works but i dont want to use CMD to open the application i wanted to start it directly as i said. 3) the bin file was not made by me and it is an executable or something of the sort, i am simple trying to make a program that once a few things are done it run run the bin program.
Prix
4) agree so i changed with @"" and am using \ instead.
Prix
+1  A: 

Hmm, this is all pretty odd. Renaming the file to .exe if it actually is an executable file seems the lower paint point. Try cmd.exe /c start /wait d:/my/path/file.bin args.

Hans Passant
if i rename it to .exe the program won't run it is compiled but i can tell that there is change verifications to it so i have to run it as it is. usually i just have a .bat to run it but now that i am making an application to run some stuff before actually running the software i wanted to make it all within the application without any bat or external things to make it work.
Prix
+1  A: 

Have you tried setting...?

myApp.UseShellExecute = true;

... and using the .bin file as your filename?

Martin Peck
Just tried it returns there is no applications associated with this extesion or something alike since my VS is in a different laguage i had to translate the error to what it would look like.
Prix