16

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?

5 Answers 5

24

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.

2
  • 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, 2019 at 22:54
  • 3
    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, 2020 at 20:00
22

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

3
  • 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, 2018 at 6:59
  • 1
    This is a better alternative if you require certian features that using share VMs disabled (like shared folders!)
    – ecnepsnai
    Sep 18, 2018 at 5:19
  • 3
    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, 2019 at 15:07
4

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.

4
  • It does not seem to handle shutting down elegantly.
    – bfrguci
    Jan 6, 2022 at 3:24
  • What do you mean by that? If I shutdown the computer, vmware does shutdown the vm properly first.
    – scotty86
    Jan 10, 2022 at 10:01
  • 1
    I see. I tried and yes it works. Thanks. @scotty86
    – bfrguci
    Jan 10, 2022 at 23:40
  • 1
    This works, however vmrun was not in my Windows path by default (obviously). You can find the executable in C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe. So the full command would be more like this if running from cmd: "C:\Program Files (x86)\VMware\VMware Workstation\vmrun" -T start "C:\Users\username\Documents\Virtual Machines\myvmname\myvmname.vmx"
    – Dave
    Mar 26, 2022 at 14:48
4

Shared VMs are deprecated:

https://communities.vmware.com/t5/VMware-Workstation-Pro/Shared-VMs-are-back-in-Workstation-16-1/td-p/2811423

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.

0

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
Next
1
  • It does not seem to handle shutting down elegantly.
    – bfrguci
    Jan 6, 2022 at 3:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .