ispiro
ispiro

Reputation: 27703

Process.Start cmd results in "is not recognized"

When launching an application directly, the application is launched, but when launched through cmd - it's not.

For example:

Works:

Process.Start("firefox");

Doesn't work:

Process.Start(
    new ProcessStartInfo
    {
        FileName = "cmd",
        Arguments = "/k firefox"
    });

I've tried setting UseShellExecute to true, but to no avail. I still get:

'firefox' is not recognized as an internal or external command, operable program or batch file.

So, yes, I can specify the complete path. But is there a way to avoid that? Or in other words - what's the difference between the two that makes the second fail?

Upvotes: 0

Views: 1348

Answers (1)

Arran
Arran

Reputation: 25076

Haven't tested it but I guess you are probably looking for the start command:

Process.Start(
    new ProcessStartInfo
    {
        FileName = "cmd",
        Arguments = "/k start firefox"
    });

As a tip, simply run "firefox" in a command prompt -> you'd get the same error message.

Upvotes: 3

Related Questions