'PHP how to get the output from vboxmanage list runningvms

When I call "vboxmanage list runningvms" I can't capture the output in PHP and echo the text.

I tried piping, redirecting, etc. and no luck.

Here is the code:

$output2=null;
$retvar=null;
echo "<h3>Check for running VMs</h3>";
$output2 = shell_exec("vboxmanage.exe list runningvms");
echo "<pre>$output2</pre>";

it returns nothing.

I also tried:

a.

$output = shell_exec("vboxmanage.exe list runningvms>runningvms.txt");

but the txt file is empty

b.

$output = shell_exec("vboxmanage.exe list runningvms 2>&1");

it returns nothing

c. Calling the version works

$output = shell_exec("vboxmanage.exe --version");

I get vbox version 6.0.24r139119 which is my test VM.

I don't know if this is STDOUT but I can't think of another way to capture the output of "list runningvms"

This is running on a Windows 7 with IIS 7. I cannot use Linux, I cannot use Apache and I cannot upgrade to Windows 10. If you find out that it works in other OSs it will make me jealous but it does not solve my problem so please focus on Windows 7 with IIS 7.

Let me know if there is another way to do this programmaticaly and send it to PHP. I could call Python and send to a text and read the text file in PHP. I will try this unless anyone here has a better way.

Thanks,



Solution 1:[1]

VirtualBox VMs are user-specific
You have to run list command using same user as VM owner

In other way you may try to add multiple users to VBox management group VBOXUSERS to be able control VMs. Here is article how to do it for Windows 7

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1