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

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.

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!

Related

Can I execute a Linux binary from a Windows application?

I want to execute a Linux binary from a QT application running on W10.
In QT we have QProcess to launch additional processes. However, since my binary is for Linux, I've thought of two possible approaches:
Running the binary in a container (i.e.: Docker, Kubernetes, Singularity...).
Executing the binary through WSL (Ubuntu) bash.
In any case, the QT application should initiate the process (the container or the bash) and, in turn, this process should launch my binary.
I've been searching on the web and I could not find something related, what makes me think that it will be difficult. For this reason, I am posting the question in order to know the viability of the proposed approaches.
EDITED
It looks like the WSL is easier, the problem is that the user has to have install ed it. Apart from requiring the sudo password when installing new software via apt-get.
The binary that I have to execute only exists for Linux, and let's say that cross-compiling is dismissed because of its complexity. Furthermore, this application needs CGAL, BOOST, MPI, among other pieces of software.
If you want to go with WSL, you can just run wsl myLinuxProgram --options.
Using WSL is the easiest way I believe as the current directory (PWD), is the current one i.e. the same as the PWD of your Qt app.
You can read Microsoft documenation for more info: https://learn.microsoft.com/en-us/windows/wsl/interop
If your linux binary depends on a lots of things, I really suggest you use docker for windows. Then, you have chance to pre-build an own docker image which put all dependency software also the linux binary you need to run in it.
Of course, to let your customer to use it, you should put it to dockerhub, register an account for yourself.
Then, the solution is simple: let the QT application to call docker run to setup a container base on your own image, execute it, and also let the linux binary to write the log or others to the bind mount volume among linux container & windows. After it run, the QT application fetch the linux binary output from this shared folder.
Finally, I give a minimal workable example for your reference:
Suppose the shared folder between windows & linux container is: C:\\abc\\log_share, it will mapped to linux container as /tmp folder. Of course you need to allow volume share by right click the docker icon in windows tray area & choose settings, like described here
Simplify the windows application as bat file, and simplfy the docker image as ubuntu, you should use your own prebuilt docker image with all dependency in it:
win_app.bat:
ECHO OFF
::New a shared folder with linux container
RD /s/q C:\\abc\\log_share > NUL 2>&1
MKDIR C:\\abc\\log_share
::From windows call docker to execute linux command like 'echo'
echo "Start to run linux binary in docker container..."
docker run -it -v C:\\abc\\log_share:/tmp ubuntu:16.04 bash -c "echo 'helloworld' > /tmp/linux_log_here.txt"
::In windows, get the log from shared bind mount from linux
echo "Linux binary run finish, print the log generated by the container..."
type C:\\abc\\log_share\linux_log_here.txt
Simplify the linux binary just as echo command in linux, the output things should be all write to shared directory:
echo 'helloworld' > /tmp/linux_log_here.txt
Now, execute the bat file with command win_app.bat:
C:\abc>win_app.bat
C:\abc>ECHO OFF
"Start to run linux binary in docker container..."
"Linux binary run finish, print the log generated by the container..."
helloworld
You can see the windows application already could fetch things(here is helloworld) which generated by linux binary from docker container.

32 bit jvm executing batch file fails with 'pnputil.exe' is not recognized as an internal or external command

I am executing batch file from 32bit Java application.
This batch/cmd tries to install some drivers using pnputil.exe on windows 7 64 bit and fails giving - 'pnputil.exe' is not recognized as an internal or external command.
Tried with changing dir to %WINDIR%/System32/ within batch file and calling pnputil.exe without any success.
However similar batch executes fine when run from 64-bit jvm.
What alternatives do I have to install INF files from 32-bit jvm executing batch file on 64-bit Windows 7 ?
I can execute pnpUtil via path %WINDIR%\sysnative\pnputil.exe for 32bit JVM.
Though sysnative is not visible via win explorer but it solved my problem.

using MPI: What on earth is "execvp error on file" error?

I am using my own laptop locally with win 10 system and intel parallel studio .
After I compiled my mpi code with mpiifort and run it with mpiexec for the first time. It warns me to input account and password, like below
I am sure I put in the correct password. But it just didn't work. What does "execvp error" mean? I never encountered this problem before on my old win8 system. I just installed this new win10 system on my laptop, everything is new. Could somebody please help me instead of making close vote without any comment? At least, say something
execvp error on file is the error from doing execvp system call. It is variant of exec system call used to start programs. In your case the mpiexec program tries to start the mpi-learning-pack.exe file on the target hosts (according to settings, probably some environment settings). This error says that it can't start your program on target hosts, because either it is not executable file, or cannot be found (not copied to target hosts or have no full path).
mpiexec does not copy file to targets, you should copy it to every target hosts.
You can also check if it executable by manually starting it on target host: just login to target host and type mpi-learning-pack.exe without mpiexec;
program may not start if there are no any of required library on target.
Or your account has no enough privileges like https://software.intel.com/en-us/forums/intel-clusters-and-hpc-technology/topic/607844 https://software.intel.com/en-us/forums/intel-clusters-and-hpc-technology/topic/624054
Or you just should use relative (mpiexec [options] .\mpi-learning-pack.exe) or full path (mpiexec [options] e:\w\work\fortran\_test_and_learning\mpi-learning-pack.exe) of target executable like in https://software.intel.com/en-us/forums/intel-clusters-and-hpc-technology/topic/624054

Why am i able to run unix commands on my PC?

How am i able to execute UNIX commands on my PC Command prompt? Note i do not have cygwin installed, although i was going to before i discovered this.
This is a development machine so i have a lot installed on it like ruby, python, git, github, node and so on.
What does this mean? can i use this without cygwin?
Here is a list of programs installed on my PC program list
How am I able to execute UNIX commands on my PC Command prompt?
You can use the where command in a cmd shell to find out the exact location of your Unix commands, for example:
where ls
This assumes, of course, that ls is located somewhere in your current PATH.
The location returned will show you in which directory your Unix commands are installed and may be enough for you to determine how they were installed.
The where command is roughly equivalent to the Unix which command.
By default, the search is done in the current directory and in the
PATH.
Syntax
WHERE [/r Dir] [/q] [/f] [/t] Pattern ...
WHERE [/q] [/f] [/t] [$ENV:Pattern
Source where
Further Reading
An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
where - Locate and display files in a directory tree.
Running Unix commands in windows can be done by having a tool like Cygwin which has those commands.
You can also get many of those commands compiled for windows and then run them using the command with the full path or only the command if the executable is in a path known by adding the paths to the executable files in Windows by :
1) Running in the terminal: PATH %PATH%;C:\<new_path>
2) Creating command aliases like: doskey np=C:\<new_path>\new_command.exe $*. $* is used to be able to transmit parameters

How to run shells like SQLite from PowerShell ISE?

I want to do some things with sqlite3.exe, the sqlite3 command line shell. After navigating to the directory in PowerShell ISE, I run the program with .\sqlite3.exe and get the expected output from SQLite:
___________________________________________________________
PS [path]\SQLite shell> .\sqlite3.exe
SQLite version 3.7.14 2012-09-03 15:42:36
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
However, if I try typing .help after this, or any other command for that matter, nothing happens and the bottom taskbar says "Already running a command. Please wait.". Of course, there is nothing to wait for, because clearly sqlite3.exe is waiting for input from me.
I cannot get PowerShell ISE to respond to any further commands after this point unless I quit SQLite with Ctrl+Break.
What is wrong?
The problem is Powershell ISE isn't like the normal Powershell console. Powershell ISE is a host built on WPF which you'll find certain legacy exe commands do not work correctly in ISE. These are normally interactive exe commands and not just sqlite3.exe. For example I've had issues with logparser.exe in ISE also.
Try running it in poweshell.exe

Resources