Autostart VMware Guest on login to Windows

Leeland's picture

After a couple days of open VMware, click box, click start, click next box, click start, click next box, click start, ...., ahhhhh!!! Today I got fed up with my "get to code" process.

With 7+ VMs I need to kick off to run development and CI testing on my laptop I needed automation. (Up till now this wasn't such a problem. But, now I have a tomcat production mirror, a CI build host (Jenkins doing C++ and Java builds), a production db mirror, a "client test box", my development desktop box, and I just added a few more boxes to run the data collection systems feeding my "test production" service using semi-random data.)

Hey I actually bought a real full blown VMware Workstation Pro license, auto-start should be just a configuration setting right? ... poke ... poke ... huh ... poke ... Google ... nope ... nope ... Dang it there has to be a way.

From a smidgen in one email thread, a smudge from another, a smattering from yet another, and a drop of blood....oops that was an odd thread to have Google pop up for my search...

The solution is actually not too bad. Essentially had to figure out the command line way to run VMs with VMware. There are two choices:

One way is "vmware.exe -x c:\vm\server1\server1.vmx" which works, but it pops up a vmware window for every call. So 7+ servers equals 7+ windows AND to top that off when I close the window I have to click on the "run in background" button WAY AWAY from where I clicked to close the window.

The other way is to use vmrun.exe which as of VMware WS v6 comes with a "nogui" option. Ah ha, all that is needed is a single batch file that is so simple it is ridiculous. Save that file as "C:\bin\startAllVMs.bat" (any location desired will work) shown below. Then create a link to that and drop the link into the start folder of the Explorer menu. Problem solved.

OH and the other problem of shutting them all down was solved by a judicious use of sudo, ssh, and a script called shutdownAllVMs.sh copied to all hosts in my ~/bin directory.

Here is my no frills C:\bin\startAllVMs.bat:

REM it ain't pretty but it works

REM start the main desktop minus the nogui option (the rest will attach)
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" -T ws start "C:\VM\ubuntu32dt_01\ubuntu32dt_01.vmx"

"C:\Program Files\VMware\VMware Workstation\vmrun.exe" -T ws start "C:\VM\tomcat-vm02\tomcat_ubuntu32srv_02.vmx" nogui
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" -T ws start "C:\VM\db-repo-vm03\db_ubuntu32srv_03.vmx" nogui
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" -T ws start "C:\VM\ci-vm04\ci_ubuntu32srv_04.vmx" nogui
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" -T ws start "C:\VM\basetest9\basetest_ubuntu32svr_v9.vmx" nogui
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" -T ws start "C:\VM\vmcnv10\vmcnv_ubuntu32svr_v10.vmx" nogui
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" -T ws start "C:\VM\vmlats10\vmlats_ubuntu32svr_v10.vmx" nogui
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" -T ws start "C:\VM\vmdds10\vmdds_ubuntu32svr_v10.vmx" nogui

exit

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Autostart VMware Guest on login to Windows

You are a god!! this has helped me so much! Thank you

you couldve said where to put the batch though

which would be saved in

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

for anyone else wondering

awesome blog

Hey, I think you create an awesome blog. Keep up the great work!

Re: Autostart VMware Guest on login to Windows

I found lots of interesting information here. The post was professionally written and I feel like the author has extensive knowledge in the subject. Keep it that way.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <em> <strong> <b> <i> <big> <small> <sub> <sup> <cite> <code> <ul> <ol> <li> <dl> <lh> <dt> <dd> <br> <p> <table> <th> <td> <tr> <pre> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <hr>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.