Open VM in c#

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
pro100pdg
Posts: 1
Joined: 21. Apr 2016, 11:47

Open VM in c#

Post by pro100pdg »

Hello,
I would like to open my VM in C# program (on button click)

i had two options :

Code: Select all

            IVirtualBox virtualBox = new VirtualBox.VirtualBox();
            foreach (IMachine machine in virtualBox.Machines)
            {
               if (machine.Name == "LinuxMint")
                {
                    virtualBox.OpenMachine();
                }             
            }
and

Code: Select all

 System.Diagnostics.Process.Start("D:\\VirtualBox\\VBoxManage.exe",@"startvm LinuxMint");
So first this is that what should i put in : virtualBox.OpenMachine(?);
And the second one is that is there any way to start some proces on that VM using the 2nd solution?
For example, after starting this LinuxMint i want to open proces "vsdesign.exe" and then go >File>Modify>Open
Last edited by noteirak on 22. Apr 2016, 13:25, edited 1 time in total.
Reason: Added code tag
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Open VM in c#

Post by noteirak »

The API call to "open" a VM, which is actually starting a VM (you are using the wrong word) is IMachine::launchVmProcess().
You have a code sample for 4.3 for it - simply update the imports to use which ever version of VirtualBox you connect to.
And the second one is that is there any way to start some proces on that VM
Yes, using a Guest Session after installing the guest additions on the VM.
Likewise, a code sample is available with the previous link
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply