Can I create shortcut on my desktop for a virtual machine?

Discussions related to using VirtualBox on Windows hosts.
tao0407
Posts: 12
Joined: 26. Feb 2009, 10:48

Can I create shortcut on my desktop for a virtual machine?

Post by tao0407 »

As tilte shown. :)
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Can I create shortcut on my desktop for a virtual machine?

Post by Perryg »

Create a batch file (CMD for NT and up) with the following in the same directory that the rest of the virtualbox files are in, then add it as a shortcut to the desktop.

Code: Select all

@echo off
cls
start virtualbox.exe --startvm Ubuntu-Karmic
@exit
Substitute the (Ubuntu-Karmic) with the actual name of the VM. If it contains spaces then use "" Example:("Ubuntu Karmic")
abcuser
Volunteer
Posts: 590
Joined: 10. May 2007, 20:03
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu, Windows XP

Re: Can I create shortcut on my desktop for a virtual machine?

Post by abcuser »

Hi,
I use the following script:

Code: Select all

@echo off
cd "C:\Program Files\Sun\VirtualBox" 
VBoxManage startvm "Ubuntu 9.10 Desktop"
Note: "Ubuntu 9.10 Desktop" is my virtual machine name.
Regards
dineshj
Posts: 34
Joined: 21. Nov 2009, 07:48
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Windows Vista

Re: Can I create shortcut on my desktop for a virtual machine?

Post by dineshj »

if you are looking for a solution in Windows environment, try the steps in this site http://virtualization.sysprobs.com/crea ... virtualbox
tao0407
Posts: 12
Joined: 26. Feb 2009, 10:48

Re: Can I create shortcut on my desktop for a virtual machine?

Post by tao0407 »

Thank you all very much!
MarkCranness
Volunteer
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

Re: Can I create shortcut on my desktop for a virtual machine?

Post by MarkCranness »

Two notes:

- VirtualBox.exe --startvm "<VMName>" is the preferred way to start a VM, rather than use the VBoxManage command.

- If the VM name contains embedded space characters, then put double-quotes around it.

Tell me what VirtualBox version you are using and what OS your VM uses and I'll build a free shortcut icon for you!
abcuser
Volunteer
Posts: 590
Joined: 10. May 2007, 20:03
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu, Windows XP

Re: Can I create shortcut on my desktop for a virtual machine?

Post by abcuser »

MarkCranness wrote:- VirtualBox.exe --startvm "<VMName>" is the preferred way to start a VM, rather than use the VBoxManage command.
I have never had any problems and I always use VBoxManage. Why is virtualbox command prefered way?
MarkCranness
Volunteer
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

Re: Can I create shortcut on my desktop for a virtual machine?

Post by MarkCranness »

VBoxManage --type GUI just calls VirtualBox.exe --startvm anyway, so you are cutting out some processing.

VBoxManage is a command line program, and so opens a command window for a short period while VirtualBox.exe runs and starts. That window is the reason for the '@echo off; cls; @exit' rhubarb whenever anyone suggests a BAT/CMD file to run a VM, which is not needed if calling VirtualBox.exe directly.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Can I create shortcut on my desktop for a virtual machine?

Post by mpack »

MarkCranness wrote:VBoxManage --type GUI just calls VirtualBox.exe --startvm anyway, so you are cutting out some processing.
That doesn't sound right to me. VirtualBox.exe is just a GUI front end for VBoxSVC, as VBoxManage is a CLI front end for it. I can't imagine why VBoxManage would call on the services of VirtualBox.exe - unless of course the "requested service" is a GUI.
MarkCranness
Volunteer
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

Re: Can I create shortcut on my desktop for a virtual machine?

Post by MarkCranness »

VBoxManage gets VBoxSVC to open a new 'session' for the VM, and VBoxSVC runs VirtualBox.exe --startvm in response.

Too much detail!:
VBoxManage handles the startvm command using internal function handleStartVM:
http://www.virtualbox.org/browser/trunk ... 25275#L365

handleStartVM calls VirtualBox::OpenRemoteSession with the required session --type (default=gui):
http://www.virtualbox.org/browser/trunk ... 25275#L378

VirtualBox::OpenRemoteSession calls Machine::openRemoteSession (I think this is now running in VBoxSvc?):
http://www.virtualbox.org/browser/trunk ... 5275#L1843

Machine::openRemoteSession creates a command line with VirtualBox.exe and parameter --startvm:
http://www.virtualbox.org/browser/trunk ... 5275#L4669

Machine::openRemoteSession creates a new process with the given command line:
http://www.virtualbox.org/browser/trunk ... 5275#L4681
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Can I create shortcut on my desktop for a virtual machine?

Post by mpack »

It still looks odd to me: have you enabled the remote display feature for this VM? I'm wondering what else a "remote session" might mean.

Bear in mind that the VirtualBox.exe process on the host can be closed once a VM is running, so it simply cannot be responsible for controlling any important service required by a running VM, at most it only starts those services, which are presumably controlled by VBoxSVC. VBoxManage could presumably start those services too, which is why I find it odd that VBoxManage needs the GUI for anything.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Can I create shortcut on my desktop for a virtual machine?

Post by Perryg »

In Windows only.
VirtualBox.exe is the GUI frontend and VBoxManage.exe is the CLI frontend.
Either one can start the VM. The problem is if you call the startvm from a command window and want the command window to go away without killing the VM you had to use VirtualBox.exe and run it as a batch statement. Now this may have changed which could be causing this confusion, but that is the way it used to be.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Can I create shortcut on my desktop for a virtual machine?

Post by mpack »

Perryg wrote:VirtualBox.exe is the GUI frontend and VBoxManage.exe is the CLI frontend.
Either one can start the VM. The problem is if you call the startvm from a command window and want the command window to go away without killing the VM you had to use VirtualBox.exe and run it as a batch statement.
Since both VirtualBox.exe and VBoxManage.exe are just front ends for VBoxSVC, and since VBoxSVC runs independantly of the command prompt, I would expect to be able to kick off a VM using "VBoxManage startvm x", and be able to close the command prompt window after the VM starts...

...and in fact I just tried it, and it did exactly what I expected it to (the command window closed when I typed "exit", the VM continued running). This experiment was done at work, where I'm still running VBox 3.0.8.


And for my next trick I tried doing exactly the same thing again, but this time I renamed "VirtualBox.exe" to prevent VBoxManage.exe from being able to find it. This time, and contrary to my expectations, the VM failed to start: I got an error message relating to the OpenRemoteSession() API that Mark mentioned a few messages back.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Can I create shortcut on my desktop for a virtual machine?

Post by Perryg »

That is what I expected to happen. I do not know when the actual condition changed but back in the V2.x days the command window had to stay open if you started it from CLI using VBoxManage.exe and if you closed it (the command window) the vm would also shutdown and show as aborted. I am sure things have changed drastically since then but since the old structure still works I use what I have been using.
MarkCranness
Volunteer
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

Re: Can I create shortcut on my desktop for a virtual machine?

Post by MarkCranness »

VirtualBox::OpenRemoteSession is what is always called: it's not dependent upon startup type or anything, I suppose that's just what Innotech decided to name the function.

If you look in Task Manager (or better yet Sysinternals Process Explorer) you will see one VirtualBox.exe for the GUI (if it is still open) and one for each running VM. Process Explorer even shows them running as child processes of VBoxSVC (because they were launched from VBoxSVC).

So I'm sure that VirtualBox.exe has two functions / does double duty:
1) The GUI we see,
2) A host window for a running VM.
Post Reply