The host is Windows 7. I would like my virtual machine to start with Windows in the background, without the need to login to Windows and manually start it. I also hope the virtual machine can be shut down elegantly upon Windows shuts down.

Is there existing script/app that does this?


If you're using VMware Workstation, you could make the VM a "Shared VM" and can configure it to automatically start (in the library, right-click on "Shared VMs" and choose "Manage AutoStart VMs"). By default, Shared VMs are subjected to a hard power-off when the host is shut down. You can change this by editing %PROGRAMDATA%\VMware\hostd\vmAutoStart.xml and changing the stopAction value to GuestShutdown (or to Suspend if you'd rather suspend the VM). You will need to restart the VMware Workstation Server service after making changes to this file (and you should shut down any running shared VMs before restarting the service).

Update: In Workstation Pro 14, the context menu item is now "Manage VM Power Actions" and now supports configuring a VM to automatically suspend when the host shuts down.

  • Ugh... that is second time I overlooked something in Library | Rt-click. Too bad it's not somewhere in the VM instance's settings. – Peter L Nov 19 '19 at 22:54
  • 2
    This is going away in Workstation 16. They brought it back in 16.1 for those who complained, but it shows "(Deprecated)" within the Library. – Corey S. Dec 2 '20 at 20:00

You can also use the vmrun command.

You can use a script to start a VM, for example:

vmrun -T ws start "F:\VMWare-VMs\S1.vmx"

and you add the script at Windows startup.

More info about vmrun

  • Easy and nice ! just put the vmrun,exe location in the path (for windows) and put this command in a bat file and call the bat file at startup – Nassim May 4 '18 at 6:59
  • This is a better alternative if you require certian features that using share VMs disabled (like shared folders!) – ecnepsnai Sep 18 '18 at 5:19
  • 2
    FYI, if your virtual machine used physical disks that require Administrative privilege with vmrun, use Task Scheduler to create a task with highest privileges. – ttimasdf Nov 20 '19 at 15:07

I'm using VMware Workstation 15.5.2 and I start my background-VMs with this command:

vmrun start "C:\VMs\D10AMP\D10AMP.vmx" nogui

The VM starts in background and no VMware window opens.


Shared VMs are deprecated:


The Shared virtual machine feature (VMware Workstation as server) is being deprecated. It will remain in its present form for the remainder of the VMware Workstation 16 product life. This feature will be not available in a future release.

There is a workaround. You can still start them manually with task scheduler via vmrun. But I have not done that personally so I can't provide details.

Great News Update: I found a January 2021 discussion where mikeroySoft from VMware hopped in with some more details:

To be clear, it’s really just the underpinning framework that we’re using to deliver that feature that’s being deprecated. I expect we’ll have a new way to ‘autostart VMs’ in the future.

The shared vm feature uses this huge component from ESXi that has sort of run its course when ported to our stack. (Hostd for those curious...) but we are looking to implement this without hostd in the future.

So the answer is: The current feature will be removed in VMware Workstation 17. Luckily, they are looking for ways to implement auto-start VMs another way after that "Shared VMs" feature is removed. Hopefully the new method is ready immediately when version 17 launches.


Thanks for scotty86's method, I just provide a more elegent method with VBS, which won't open a cmd window when the command running.

Save the following code as vmrun.vbs in startup folder.

Set oShell = CreateObject ("Wscript.Shell")
Dim cmdStrs : cmdStrs = Array( _
    """C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe"" start ""C:\Virtual Machines\Debian_10_01\Debian_10_01.vmx"" nogui", _
    """C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe"" start ""C:\Virtual Machines\Debian_10_02\Debian_10_02.vmx"" nogui" _

For Each cmdStr In cmdStrs
    oShell.Run cmdStr, 0, false

Doing it as a service is extremely difficult, and defeats the purpose of services, due to the fact that executables are supposed to utilize [ServiceMain] to be able to even be used as a service in the first place. However, if you want the same functionality of starting at boot, even before the user logs in, the truly most-consistent option is to use Task Scheduler.

Implementing the solution

This requires a couple of pretty easy steps, but I will explain them in detail to ensure anyone from with any technical background can set this up:

  1. Identify your virtual machine name
  2. Create a task in Task Scheduler

1. Identify your virtual machine name

Navigate to C:\Users\YourUserNameHere\VirtualBox VMs

VirtualBox VMs Folder

The folder name above generally reflects the virtual machine name. You can confirm this by checking VirtualBox Manager itself:

VirtualBox GUI

The machine name is WindowsXPSP3.

2. Create a task in Task Scheduler

First click the start button and type "task scheduler" without the quotes. Then open the Task Scheduler:

Task Scheduler Search

Inside the task scheduler, we're going to see a structure tree on the left side. Right-click on Task Scheduler Library. Left-click on New Folder...:

Task Scheduler New Folder

Name the folder something memorable, like User Custom and hit OK (if you already have an existing folder that you would prefer to use, that's fine as well, skip to the next paragraph instead):

Name New Folder

Click your newly created folder, in my case User Custom, to highlight it. Right-click in the empty list to the right and Left-click on Create New Task...:

Create New Task

Now comes the tricky stuff. Follow my instructions verbatim. If you feel like downvoting because it didn't work, or say "this didn't work for me" in the comments, I'm betting you skipped a step here. Come back and try it again.

The Name and Description can be whatever you like, it is merely aesthetic and will not affect functionality. I'm going to name mine after my virtual machine and put a brief description. What IS important is that you choose Run whether user is logged on or not and Run with highest privileges:

Create Task: General

Switch to the Triggers tab at the top and Left-click New.... Switch the Begin the task: combination box to At Startup and then Left-click OK:

New Trigger

Switch to the Actions tab at the top and Left-click New.... Click browse (do not try to type this manually, you will cause yourself headaches) and navigate to C:\Program Files\Oracle\VirtualBox. Highlight VBoxManage.exe and Left-click Open:

Browse to VBoxManage

Copy everything except the executable and the quotation marks from Program/script: into Start in (optional)::

Copy Directory Path

Finally, put the following line into Add arguments (optional): and hit OK:

startvm "YourVirtualMachineNameFromStep1" --type headless

in my case, I will use:

startvm "WindowsXPSP3" --type headless

Enter Arguments

My Conditions tab is generally set to the following:

Conditions Tab

Make sure your Settings tab looks like the following, but absolutely ensure you have set the items marked in yellow to match mine. This will make sure that if some pre-requisite wasn't ready yet that it will retry a few times to start the virtual machine and that the virtual machine won't be terminated after 3 days. I would leave everything else as default unless you know what you are doing. If you don't do what I show you here, and it ends up not working, it's your problem:

Settings Tab

Finally, hit OK at the bottom of the Create Task window. You are done!

Testing the solution

Testing My Fake Scenario Above (and how you can test yours)

When I restart my computer, I can log in and open the VirtualBox Manager and see that my VM is running:

Running VM

I can also open Task Scheduler back up, and verify that it ran successfully, or see what the error was if it did not (most errors will be directory errors from people trying to manually enter where I told them not to):

Task Scheduler Success

Testing My Actual Use Case

On another machine, I set up my Linux Server as a virtual machine with it's own raw solid-state hard drive. I wanted that Server to boot back up if the machine got restarted (crash, windows update, etc) automatically, without the user having to log in. I set that one up exactly as I described above and restarted that machine. I know it worked successfully because I was able to access my Samba share (laymens: a folder with stuff in it that I share over my network to my other computers) from another computer WITHOUT having first logged into the machine that runs the Server VM. This 100% confirms that it does start on system boot and not after the user logs in.

  • You can simply change the Begin the task: to At logon instead of At Startup and Run only when user is logged on instead of Run whether the user is logged on or not, if you desire it to occur ONLY AFTER the user logs into the system. – DeeJayh Apr 28 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.