C# nbtstat 进程找不到指定的文件
C# nbtstat process cannot find specified file
我正在尝试使用 nbtstat
获取我们客户的 mac 地址。我正在使用 System.Diagnostics.Process
来执行命令。
Process p = new Process();
p.StartInfo.FileName = "nbtstat";
p.StartInfo.Arguments = string.Format("-a {0}", principal.Name);
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
不幸的是,代码抛出异常。
The system cannot find the file specified.
如果 nbtstat 的 exe 文件在 System32 文件夹中,它应该可以在没有我认为的完整路径的情况下工作。但我还是用完整路径试了一下。
p.StartInfo.FileName = @"C:\Windows\System32\nbtstat.exe";
代码仍然抛出异常。我可以使用其他命令,如 ipconfig
、getmac
、ping
等。只是 nbtstat
导致了问题。我仔细检查了 nbtstat.exe
的目录,它在正确的文件夹中。我也试过像这样使用 ProcessStartInfo
:
ProcessStartInfo info = new ProcessStartInfo();
// set properties like above
Process.Start(info);
这也无济于事(如果这行得通,我会感到困惑,但上面的代码不行,因为它应该完全一样,对吧?)。
我正在使用 Windows Forms 和 .NET Framework 4.5。
切换到任何 cpu 或检查 os verizon 并获取环境路径,查看
我正在尝试使用 nbtstat
获取我们客户的 mac 地址。我正在使用 System.Diagnostics.Process
来执行命令。
Process p = new Process();
p.StartInfo.FileName = "nbtstat";
p.StartInfo.Arguments = string.Format("-a {0}", principal.Name);
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
不幸的是,代码抛出异常。
The system cannot find the file specified.
如果 nbtstat 的 exe 文件在 System32 文件夹中,它应该可以在没有我认为的完整路径的情况下工作。但我还是用完整路径试了一下。
p.StartInfo.FileName = @"C:\Windows\System32\nbtstat.exe";
代码仍然抛出异常。我可以使用其他命令,如 ipconfig
、getmac
、ping
等。只是 nbtstat
导致了问题。我仔细检查了 nbtstat.exe
的目录,它在正确的文件夹中。我也试过像这样使用 ProcessStartInfo
:
ProcessStartInfo info = new ProcessStartInfo();
// set properties like above
Process.Start(info);
这也无济于事(如果这行得通,我会感到困惑,但上面的代码不行,因为它应该完全一样,对吧?)。
我正在使用 Windows Forms 和 .NET Framework 4.5。
切换到任何 cpu 或检查 os verizon 并获取环境路径,查看