Running external exe from Unity

Hi!
When I use this code:

                    path += "/qemu/Win98";
                    using (Process process = new Process())
                    {
                        //process.StartInfo.UseShellExecute = false; 
                        //process.StartInfo.CreateNoWindow = true;
                        process.StartInfo.WorkingDirectory = path;
                        process.StartInfo.Arguments = "-m 256 -boot d " + (path + "/w98.cow") + " -vnc 0.0.0.0:1";
                        process.StartInfo.FileName = path + "/../qemu-system-x86_64.exe";
                        process.Start();
                    }

The path is perfectly fine, (I checked it with Debug.Log) but the cmd just pops out for 1 millisecond (or less). I tried everything, but this is not working for me.

Bump

Are you trying to open a Command prompt, or an excecutable file? This works fine for me:

void Start () {
    Process p = new Process();
    p.StartInfo.UseShellExecute = true;
    p.StartInfo.FileName = "C:\\Windows\\System32\\cmd.exe";
    p.Start();
}

You could try passing “pause” as one of the arguments to see if there’s any errors in the cmd window. Though I’m not too sure if that would work.

I am trying to open the exe file, but it’s not opening. It has to create a qemu virtual machine that opens a VNC server. I can start it from anywhere, but this approach is not working. (The -pause argument do nothing.)

“/…/qemu-system-x86_64.exe’ is not recognized as an internal or external command,
operable program or batch file.” I think my bat file is not working. Oh, how can I point to that exe? It’s one folder up.

I made some changes to the bat file, now everything works.

Nice to see that you worked it out. For people who have this problem in future:
Run the .exe manually before trying to get your program to run it!

2 Likes