Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

netsh mbn show interfaces results in command not found on Win7 64Bit

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.

like image 514
Mario Van den Eynde Avatar asked Mar 30 '12 13:03

Mario Van den Eynde


1 Answers

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!

like image 135
Mario Van den Eynde Avatar answered Oct 16 '22 02:10

Mario Van den Eynde