Tips, Hints, Cheats, Tools

Input Director : http://www.inputdirector.com/ Share one mouse/keyboard via multiple computer.
Mentioned by Ajay (@ajay184f) on 20.12.2010 via Twitter.

Are you working on a host computer with a virtual environment like VMWorkstation and need to start and stop your VM machines regularly?

Here is “How To” to create a small batch file; which i use at work:
1. Open notepad (or other text editor)
2. Save file as “start.bat”.
IMPORTANT!: Then extension must read “start.BAT”, not “start.bat.TXT” as some editors do.
3. Copy following lines into file and save afterwards again.

    REM Start VM machines after system reboot –> Any line with REM is a comment and not executed.

    REM First to start: Database maschine –> I like to have my DB machine up first.. otherwise our program throws errors at service start.
    “C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe” -T ws start “D:\VMMachines\1_RUN\QS_Pink\WinXPprof-en.vmx”

a) I put full qualified path to vmrun.exe.. if you put it into your PATH environment, you could shorten it to only use vmrun.exe.
b) -T ws –> you have to tell that you are using VM Workstation (ws)
c) start –> the actual parameter for vmrun.exe
d) Full qualified path to VMX file, which starts the VM template.

    CHOICE /N /C YN /T 5 /D Y > NUL

a) You can read it up.. important is the digit 5 here.. which puts a 5 sec delay.
Why do i put that? I like to create a delay between the start commands.
Since i am not a batch programmer, that is my implementation. *shrug
You can read it up.. important is the digit 5 here.. which puts a 5 sec delay.

REM Second to start: Fileserver maschine
“C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe” -T ws start “D:\VMMachines\2_STANDBY\QS_SamyD\Windows Server 2008 x64 Edition (experimental).vmx”

a) Repeat that section for all machines you need.

The STOP batch is basically the same.
1. Copy start.batch to stop.batch.
2. Open with notepad, replace START with STOP.
3. Reverse the stop order.. i put my database machine last to stop.

4. One new command:

    REM Shutdown the VM Host machine
    shutdown /s

a) At the end of the day or before a weekend, when i stop my VMs, i go home.
So i use this command to shutdown the host machine.

Last Action:
1. Copy or link the start.bat in the “Startup” folder of Windows.
Whenever you log into your machine, it will execute the batch file and therefore start your machines for you.

Sideeffect:
When using the stop batch, it stops the VMs like in a few seconds.
When you have ever waited for VISTA or W7 to shutdown (in office network takes like 20 minutes) you will go “woot”!!

So far i have seen no corruption or “bad” influences by shutting them down with the vmrun.exe -stop command.

Next section will cover how to start the VMs when you start your host maschine with the Windows scheduler.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>