Jeffrey Chen
Jeffrey Chen

Reputation: 77

How to run a command process with C#

I want to run a command process with C# and see the version of NodeJS

using (Process process = Process.Start(new ProcessStartInfo()
                           { 
                             FileName="cmd.exe", 
                             Arguments = "node -v"
                           }))
{
    process.WaitForExit();
}

but I only see a command prompt without NodeJS version, any idea? thanks

Upvotes: 0

Views: 93

Answers (1)

Vivek Nuna
Vivek Nuna

Reputation: 1

This is working for me.

using (Process process = Process.Start(new ProcessStartInfo()
{
    FileName = "cmd.exe",
    Arguments = "/C node -v",
}))
{
    process.WaitForExit();
}

Upvotes: 1

Related Questions