diff --git a/bat/vmware-batch.bat b/bat/vmware-batch.bat new file mode 100644 index 0000000..fa55ba7 --- /dev/null +++ b/bat/vmware-batch.bat @@ -0,0 +1,319 @@ +@echo off +Setlocal enabledelayedexpansion +::CODER BY lework + +title VMware Workstation 虚拟机批量管理 + +IF EXIST "%PROGRAMFILES%\VMWare\VMWare Workstation\vmrun.exe" SET VMwarePath=%PROGRAMFILES%\VMWare\VMWare Workstation +IF EXIST "%PROGRAMFILES(X86)%\VMWare\VMWare Workstation\vmrun.exe" SET VMwarePath=%PROGRAMFILES(X86)%\VMWare\VMWare Workstation +IF EXIST "%PROGRAMFILES%\VMware\VMware VIX\vmrun.exe" SET VMwarePath=%PROGRAMFILES%\VMware\VMware VIX +IF EXIST "%PROGRAMFILES(X86)%\VMware\VMware VIX\vmrun.exe" SET VMRUN=%PROGRAMFILES(X86)%\VMware\VMware VIX + +::变量设置 +::set VMwarePath="C:\Program Files (x86)\VMware\VMware Workstation" +set VMpath="D:\Virtual Machines" +set VMname=CentOS_7.4_x64_node +set VMSnapshot=init +set VMcount=5 +set VMowa="D:\vmware owa\CentOS_7.4_x64.ova" +set VMuser=root +set VMpass=123456 +set VMipStart=10 +set VMnetwork=192.168.77 + + +:init +cls +echo. +echo. VMware Workstation 虚拟机批量管理 +echo. +echo ============================== +echo. +echo. 输入 0 一键初始化(包含1,2,3步骤) +echo. 输入 1 创建虚拟机 +echo. 输入 2 设置ip地址 +echo. 输入 3 创建快照 +echo. 输入 4 查看启动的虚拟机 +echo. 输入 5 启动虚拟机 +echo. 输入 6 关闭虚拟机 +echo. 输入 7 重启虚拟机 +echo. 输入 8 恢复虚拟机快照 +echo. 输入 9 删除虚拟机 +echo. 输入 10 挂起虚拟机 +echo. 输入 11 暂停虚拟机 +echo. 输入 12 恢复虚拟机 +echo. 输入 q 退出 +echo. +echo ============================== +echo. + +cd /d "%VMwarePath%" + +set "input=" +set /p input=请输入您的选择: +echo. +if "%input%"=="q" goto exit +if "%input%"=="0" goto oneKey +if "%input%"=="1" goto create +if "%input%"=="2" goto setip +if "%input%"=="3" goto snapshot +if "%input%"=="4" goto list +if "%input%"=="5" goto start +if "%input%"=="6" goto stop +if "%input%"=="7" goto restart +if "%input%"=="8" goto revertToSnapshot +if "%input%"=="9" goto delete +if "%input%"=="10" goto suspend +if "%input%"=="11" goto pausevm +if "%input%"=="12" goto unpausevm + +:wait +echo. +echo 执行完毕, 等待中... +for /l %%a in (1,1,5) do ( +ping /n 2 127.1>nul +set /p a=^>nul +exit \ No newline at end of file