VMware Workstation "vmrun" command don't work into a startup .bat file

5,014

If you've scheduled a task to run without a user being logged on (which you have, because nobody is logged on while the system is booting up), the program cannot display any user interface because it runs in a session intended for only background services. Windows tells you about this situation with that message.

To start a VM with the vmrun command with no UI, add nogui at the end, like this:

vmrun.exe -T ws start "D:\VM\Name.vmx" nogui

(Source: this PDF VMWare manual.)

To fix the VM thinking it's in use, you need to delete or move the .lck or .lock files/folders from where the virtual machine is stored while VMWare Workstation isn't running. (Source: VMWare forums.)

Share:
5,014

Related videos on Youtube

Ophion
Author by

Ophion

Obtained an engineering degree at Computer Sciences University (UCI in Cuba). Currently working as SysAdmin. Interested in horticulture and Artificial Intelligence. Love to play World of Warcraft and to watch playing FC Barcelona (soccer).

Updated on September 18, 2022

Comments

  • Ophion
    Ophion over 1 year

    I need to start a virtual machine on Windows Startup and read about move the virtual machine to the "Shared VMs" tab. This worked for me since now when I need to auto start a Virtual Machine with a Physical Disk reference. By default VMware Workstation won't allow you to do this if you are loading a physical disk (from host machine).

    I started to search for a solution and found some info about the "vmrun" command which allows you to start a virtual machine using the Windows Console (cmd.exe). Turns out that it works! If you execute something like this:

    vmrun.exe -T ws start "D:\VM\Name.vmx"

    The virutual machine starts immediately. So far we are good. Now, If I create a batch script (.bat) with the same line and configure the system to execute that batch file on startup nothing happens and I got this system prompt:

    https://s23.postimg.org/ggtpy0zqj/Servicios_Interactivos.png

    Also I got my VM blocked and force me to Take ownership, which I can't and finally offers me the alternative to Remove the VM from library.

    This confuses me because I can start the VM from a command prompt but I can't do the same using a .bat file.

    PS: I modified the windows environment variables to allow me to type only the vmrun command without pointing the entire path to the .exe. Somehow the system tries to execute the Virtual Machine (which says the .bat is executed) and finally can't do it completely.

    **Post edit: I'm using the NSSM program to set other programs to run as services, which by the way I found in this great platform.

  • Ophion
    Ophion over 7 years
    Oh man, oh man, oh man. This solved my headache about this issue. By the way I faced this same problem in VirtualBox and finally drop the flag. Now finally have the solution. Im still getting the windows prompt and I don't know why but, who cares? My VM is running in background! :) :) In your face Interactive environment.
  • Ophion
    Ophion over 7 years
    Seriously, I read something related to do not say thanks on posts but anyway THANK YOU!
  • Admin
    Admin almost 2 years
    Thank you, 6 years later and this is still a solution to an incredibly annoying deadlock situation where a VM is not starting through Task Scheduler if "nogui" is not set as a parameter, the VM attempts to start up and just hangs at a certain point, with no way to interact with it except shutting down its task through TaskMgr. I have 3 VMs running in a System, 2 start without nogui, the third one made me waste hours troubleshooting the issue...I didn't even get the message that the VM was attempting to display something because it had nothing to display, it simply hangs, ridiculous...