Question

I'm trying to run "netsh mbn show interfaces" from a .bat or .jar file on a Windows 7 64bit system but every time I run my file, it results in "The following command was not found mbn show interfaces".

When I run that same command in a cmd.exe prompt, the result is correct and as expected. When we run /? we see "mbn" in available commands. When we output that same result from a .bat or .jar, we don't see that "mbn" command in the available commands for netsh.

Anybody know what's happening? We know there are 2 netsh.exe files, one in sys32 and one in syswow64.

All help is appreciated.

Was it helpful?

Solution

we solved the problem:

When running the command "netsh mbn show interface" was running the cmd as a 64bit operation. When running the command from an application - that is 32bit - the cmd is run as a 32bit operation. And the mbn-context is not available in 32bit.

In a windows 64bit os, a behind the scenes function exists: file system redirection. Meaning: a 64bit process will call the equivalent 32bit process.

The workaround is that you use a csharp script or something else where you can override the file system redirection:

IntPtr ptr = IntPtr.Zero;
Wow64DisableWow64FsRedirection(ref ptr);
// -- your proces information here --
Wow64RevertWow64FsRedirection(ptr);
//always revert the operation.

and that solved it!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top