- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 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 窗体和 .NET Framework 4.5。
最佳答案
切换到任何 cpu 或检查操作系统版本并获取环境路径,看看 https://stackoverflow.com/a/21028022/87956
关于C# nbtstat 进程找不到指定的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35224442/
我正在尝试使用 nbtstat 获取我们客户的 mac 地址。我正在使用 System.Diagnostics.Process 来执行命令。 Process p = new Process(); p.
我有一段代码可以使用 System.Diagnostic.Process 执行命令。但是,当我尝试使用相同的代码运行 nbtstat 时,它没有返回任何内容(也没有异常)。当我运行主机名(作为示例)时
我正在尝试使用 shell_exec() 从 PHP 调用 nbtstat 命令。显然这不起作用,因为我使用的是 64 位系统。 echo shell_exec("nbtstat"); 我做了一些研究
我是一名优秀的程序员,十分优秀!