Skip to content

Instantly share code, notes, and snippets.

@Firxiao
Created May 26, 2021 13:39
Show Gist options
  • Save Firxiao/08c8c0fb33b358b97ee896dcbb3c119b to your computer and use it in GitHub Desktop.
Save Firxiao/08c8c0fb33b358b97ee896dcbb3c119b to your computer and use it in GitHub Desktop.
@echo off
rem Start Stop VMware VMs via vmrun
cls
:: Defein VM names
set VMs=k8s-master01 k8s-node01 k8s-node02 k8s-node03
set VMLocation=C:\Users\xf\Documents\Virtual Machines\
set VMwarePATH=D:\Program Files (x86)\VMware\VMware Workstation
color 0a
TITLE VMware VMs Manager
CLS
:MENU
echo. *****Running VMs ******
"%VMwarePATH%\vmrun" list
echo.
::*************************************************************************************************************
echo.
echo. [1] Start k8s VMs
echo. [2] Stop k8s VMs
echo. [3] Check VMs Status
echo. [0] Exit
echo.
echo. Please input your choice:
set /p ID=
IF "%id%"=="1" GOTO start
IF "%id%"=="2" GOTO stop
IF "%id%"=="3" GOTO MENU
IF "%id%"=="0" EXIT
PAUSE
:start
call :startVMs
GOTO MENU
:stop
call :shutdownVMs
GOTO MENU
:shutdownVMs
echo.
for %%i in (%VMs%) do (
echo shutdown %%i
"%VMwarePATH%\vmrun" stop "%VMLocation%\%%i\%%i.vmx"
)
echo.OK
goto :eof
:startVMs
echo.
for %%i in (%VMs%) do (
echo start %%i
"%VMwarePATH%\vmrun" start "%VMLocation%\%%i\%%i.vmx"
)
echo.OK
goto :eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment