Sometimes we need a solution to automatic start VMs after a reboot... So here's some basic commands for automatic start VMs after reboot..
Step 1. Create a file called "Start_VM.bat"
Step 2. Write the Following Code in the File:
:: The command "echo off" turns off the display for the whole script, except for the "echo off" command itself.
@echo off
:: The Path of Where VMware Installed
cd "C:\Program Files (x86)\VMware\VMware Workstation"
:: To list the running VM
vmrun -T ws list
:: To Start a VM, the location of the VMs usually it's located inside the User's Documents
vmrun -T ws start "C:\Users\Example\Documents\Virtual Machines\CentOS 7\CentOS 7.vmx"
:: To Stop a VM
vmrun -T ws start "C:\Users\Example\Documents\Virtual Machines\CentOS 7\CentOS 7.vmx"
:: To restart a VM
vmrun -T ws restart "C:\Users\Example\Documents\Virtual Machines\CentOS 7\CentOS 7.vmx"
:: To pause a VM
vmrun -T ws pause "C:\Users\Example\Documents\Virtual Machines\CentOS 7\CentOS 7.vmx"
Note : If you only start a VM the Comment all lines except start line.. You can comment a line using :: in front of a line...
Step 3. Save it
Step 4. Now create a task using "Windows Task Scheduler" which work on startup.
First Method to do this:
To run a batch file at start up: start >> all programs >> right-click startup >> open >> right click batch file >> create shortcut >> drag shortcut to startup folder.
The path to the folder is : [D|C]:\Profiles\{User}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
That's it!!
Step 1. Create a file called "Start_VM.bat"
Step 2. Write the Following Code in the File:
:: The command "echo off" turns off the display for the whole script, except for the "echo off" command itself.
@echo off
:: The Path of Where VMware Installed
cd "C:\Program Files (x86)\VMware\VMware Workstation"
:: To list the running VM
vmrun -T ws list
:: To Start a VM, the location of the VMs usually it's located inside the User's Documents
vmrun -T ws start "C:\Users\Example\Documents\Virtual Machines\CentOS 7\CentOS 7.vmx"
:: To Stop a VM
vmrun -T ws start "C:\Users\Example\Documents\Virtual Machines\CentOS 7\CentOS 7.vmx"
:: To restart a VM
vmrun -T ws restart "C:\Users\Example\Documents\Virtual Machines\CentOS 7\CentOS 7.vmx"
:: To pause a VM
vmrun -T ws pause "C:\Users\Example\Documents\Virtual Machines\CentOS 7\CentOS 7.vmx"
Note : If you only start a VM the Comment all lines except start line.. You can comment a line using :: in front of a line...
Step 3. Save it
Step 4. Now create a task using "Windows Task Scheduler" which work on startup.
First Method to do this:
- Log in with an Administrator account
- Click on start and type “Task Scheduler” and hit return
- Click on “Task Scheduler Library”
- Click on “Create New Task” on the right hand side of the screen and set the parameters as follows:
a. Set the user account to SYSTEM
b. Choose "Run with highest privileges"
- Click on “Triggers” tab and then click on “New…” Choose “At Startup” from the drop down menu, click Enabled and hit OK
- Click on the “Actions tab” and then click on “New…” Then locate the file...
- Click on “OK” then on “OK” on the create task panel and it will now be scheduled.
- Add the .bat script to the place specified in your task event.
- Enjoy.
To run a batch file at start up: start >> all programs >> right-click startup >> open >> right click batch file >> create shortcut >> drag shortcut to startup folder.
The path to the folder is : [D|C]:\Profiles\{User}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
That's it!!