Command not recognized on calling through a C# .NET application but works when called directly

Viewed 179

I am running a .NET application on wine in linux. I am trying to run a command that runs a shell script present in the linux. This is my code inside the .NET application, calling the command:

           System.Diagnostics.Process process = new System.Diagnostics.Process();
           System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
           startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
           startInfo.FileName = "cmd";
           startInfo.Arguments = "/C /bin/gnome-terminal -- sh -e /bin/MyScripts/script.sh";
           process.StartInfo = startInfo;
           process.Start();

The gives me error saying that

Can't recognize /bin/gnome-terminal -- sh -e /bin/MyScripts/script.sh as as an internal or external command, operable program or batch file.

However, if I try to run that command directly on wine, that command works fine and executes the script. I have tried running it directly like this:

wine cmd /c /bin/gnome-terminal -- sh -e /bin/MyScripts/script.sh

The application is run on wine using the following command:

wine Application.exe

So I assume if that application runs the command, it will be called the same way it is called directly, so why I am seeing such inconsistent behaviour? What am I doing wrong and what change should I make for the command to work through the application?

1 Answers

Try

startInfo.FileName = "cmd.exe";
Related