King Computer Solutions
spacer
11.27.2012

Script to Shut down and backup vmware virtual machines in Windows

This script

  1. shuts down the vmware virtual machines called SBS and TS
  2. Stops Windows services
  3. copies them from C:\virtualmachines to D:\virtualmachines
  4. restarts the services
  5. restarts the vmware machines

@rem ———- Stop the Terminal Server ———-

call “vmrun.exe” -T server -h https://localhost:8333/sdk -u administrator -p AdminPassword stop
“[VMs] TS/TS.vmx” soft

@rem ———- Stop the SBS Server ———-
call “vmrun.exe” -T server -h https://localhost:8333/sdk -u administrator -p AdminPassword stop
“[VMs] SBS/SBS.vmx” soft

NET STOP “VMware Host Agent”
NET STOP “VMware Authorization Service”
NET STOP “VMware DHCP Service”
NET STOP “VMware NAT Service”
NET STOP “VMware Server Web Access”

XCOPY “C:\VirtualMachines\*.*” “D:\VirtualMachines” /y /e /s

NET START “VMware Host Agent”
NET START “VMware Authorization Service”
NET START “VMware DHCP Service”
NET START “VMware NAT Service”
NET START “VMware Server Web Access”

@rem VMware Command Line Local Admin / Password Event “[Datastore] VMX-File Path”

@rem ———- Start the Terminal Server ———-
call “vmrun.exe” -T server -h https://localhost:8333/sdk -u administrator -p AdminPassword start
“[VMs] TS/TS.vmx”
@rem ———- Start the SBS Server ———-
call “vmrun.exe” -T server -h https://localhost:8333/sdk -u administrator -p AdminPassword start
“[VMs] SBS/SBS.vmx”