C # nbtstat process cannot find the specified file

I am trying to get the mac address of our customers using nbtstat. I use System.Diagnostics.Processto execute the command.

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();

Unfortunately, this code throws me an exception.

The system cannot find the specified file.

If the nbtstat exe file is in the System32 folder, it should work without the full path that I thought. But I tried this using the full path.

p.StartInfo.FileName = @"C:\Windows\System32\nbtstat.exe";

The code still throws an exception. I can use other commands, such as ipconfig, getmac, ping, etc. This is just nbtstatwhat causes the problem. I double checked the directory nbtstat.exe, it is in the right folder. I also tried using ProcessStartInfoas follows:

ProcessStartInfo info = new ProcessStartInfo();
// set properties like above
Process.Start(info);

( , , , , ?).

Windows Forms .NET Framework 4.5.

+4
1

swtich , os verison , fooobar.com/questions/1627440/...

+2

Source: https://habr.com/ru/post/1627439/


All Articles