如何使用 C# 运行 命令进程

How to run a command process with C#

我想 运行 使用 C# 进行命令处理并查看 NodeJS 的版本

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

但我只看到没有 NodeJS 版本的命令提示符,知道吗?谢谢

这对我有用。

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