Setup automatic VM start
Windows Scheduler is good tool to start VM. Simply add new task to execute application during system start up. Put full path to vmplayer.exe as application name (C:\Program Files (x86)\VMware\VMware Player\vmplayer.exe) and path to VM configuration file as application parameter (e.g. C:\VMServers\SVN\SVN.vmx). Disable all unnecessary execution options set by default then save created job. Unfortunately solution requires second part. Player starts VM right after reboot well but does not power off server during shutdown or reboot. So VM state could be inconsistent after reboot.Add automatic VM shutdown
VMWare player does not allow to shutdown of existing VM using command line. But VMWare VIX does. Now shutdown event should be catched up. Windows scheduler does not allow to run any tasks on shutdown but LocalSystem policy can be used to run specific script during system shutdown. Start Run dialog (Win+R) then type gpedit.msc then Enter. In opened local group policy editor select System Configuration/Windows Settings/Scripts (Startup/Shudown). And add Shotdown.bat as shutdown script. Shudown.bat includes just single line:"C:\Program Files (x86)\VMware\VMware VIX\vmrun.exe" -T player suspend C:\VMServers\SVN\SVN.vmx
It should be saved as C:\Windows\System32\GroupPolicy\Machine\Scripts\Shutdown\Shutdown.bat (note that GroupPolicy is hidden folder and administrative rights are needed to write to this folder).
Reasonable question is why not to use local group policy startup script to start VM instead of scheduler. Unfortunately this does not work. Perhaps because not all necessary services started for VmWare Player
Hints
Replace suspend with shutdown if you need to make VM reboot for some reason.
VMWare Server allows to attach to console of auto-started VM. Unfortunately this is not the case for Player. Started instance is running on another desktop so cannot be viewed. In case of any problem VM can be suspended then started again using vmrun.exe. In this case restored VM should start on current desktop:
"C:\Program Files (x86)\VMware\VMware VIX\vmrun.exe" -T player suspend C:\VMServers\SVN\SVN.vmx "C:\Program Files (x86)\VMware\VMware VIX\vmrun.exe" -T player start C:\VMServers\SVN\SVN.vmx
No comments:
Post a Comment