You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

349 lines
8.7 KiB

4 years ago
@echo off
Setlocal enabledelayedexpansion
::CODER BY lework
:: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>谲װvmtool
title VMware Workstation <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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
:: VMware<EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD>ַ
# set VMwarePath="C:\Program Files (x86)\VMware\VMware Workstation"
:: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
set VMpath="D:\Virtual Machines"
:: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
set VMname=Debian_10.2_x64_node
:: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
set VMSnapshot=init
:: <EFBFBD>½<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
set VMcount=5
:: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>owaģ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
set VMowa="D:\vmware owa\Debian_10.2_x64_base.ova"
:: ģ<EFBFBD><EFBFBD>ϵͳ<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>
set VMuser=root
:: ģ<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
set VMpass=123456
:: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
set VMnetwork=192.168.77
:: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ip<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ
set VMipStart=180
:init
cls
echo.
echo. VMware Workstation <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo.
echo ==============================
echo.
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1,2,3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ip<EFBFBD><EFBFBD>ַ
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 4 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 6 <EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 7 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 8 <EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 9 ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 10 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 11 <EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 12 <EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 13 ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> q <EFBFBD>˳<EFBFBD>
echo.
echo ==============================
echo.
cd /d "%VMwarePath%"
set "input="
set /p input=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>:
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
if "%input%"=="13" goto delsnapshot
:wait
echo.
echo ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD>...
for /l %%a in (1,1,5) do (
ping /n 2 127.1>nul
set /p a=^><nul
)
cls
goto init
:oneKey
echo [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set "cname="
set "ccount="
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
set /p VMSnapshot=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMSnapshot%):
set /p VMuser=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMuser%):
set /p VMpass=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMpass%):
set /p VMipStart=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ip<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>:%VMipStart%):
echo.
echo =============
echo.
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>: !VMowa!
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼: !VMpath!
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMname!
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMcount!
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMSnapshot!
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>: !VMuser!
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMpass!
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMnetwork!
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ip<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ: !VMipStart!
echo.
echo =============
for /l %%a in (1,1,!VMcount!) do (
echo.
echo <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMname!%%a
cd OVFTool
ovftool --name=!VMname!%%a !VMowa! !VMpath!
cd ..
echo.
echo <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMname!%%a
vmrun -T ws start !VMpath!\!VMname!%%a\!VMname!%%a.vmx
)
echo.
echo <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ip:
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
set /a num=%VMipStart%+%%a-1
set ip=!VMnetwork!.!num!
echo !name!:!ip!
vmrun -T ws -gu !VMuser! -gp !VMpass! runProgramInGuest !VMpath!\!name!\!name!.vmx -noWait /bin/bash -c "echo 'node!num!' > /etc/hostname && echo '127.0.0.1 node!num!' >> /etc/hosts; sudo sed -i 's/IPADDR=.*$/IPADDR="!ip!"/g' /etc/sysconfig/network-scripts/ifcfg-e* || sudo sed -i 's/address .*$/address !ip!/g' /etc/network/interfaces; init 6" nogui
)
echo.
echo <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo !name!
vmrun -T ws stop !VMpath!\!name!\!name!.vmx nogui
vmrun -T ws snapshot !VMpath!\!name!\!name!.vmx !VMSnapshot! nogui
vmrun -T ws start !VMpath!\!VMname!%%a\!VMname!%%a.vmx nogui
)
goto wait
:start
echo [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo !name!
vmrun -T ws start !VMpath!\!name!\!name!.vmx nogui
)
goto wait
:stop
echo [<EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo !name!
vmrun -T ws stop !VMpath!\!name!\!name!.vmx nogui
)
goto wait
:restart
echo [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo !name!
vmrun -T ws stop !VMpath!\!name!\!name!.vmx nogui
vmrun -T ws start !VMpath!\!name!\!name!.vmx nogui
)
goto wait
:suspend
echo [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo !name!
vmrun -T ws suspend !VMpath!\!name!\!name!.vmx nogui
)
goto wait
:pausevm
echo [<EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo !name!
vmrun -T ws pause !VMpath!\!name!\!name!.vmx nogui
)
goto wait
:unpausevm
echo [<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo !name!
vmrun -T ws unpause !VMpath!\!name!\!name!.vmx nogui
)
goto wait
:revertToSnapshot
echo [<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
set /p VMSnapshot=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMSnapshot%):
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo !name!
vmrun -T ws revertToSnapshot !VMpath!\!name!\!name!.vmx !VMSnapshot! nogui
)
goto wait
:list
echo [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>...]
vmrun list
echo.
pause
goto wait
:create
echo [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set "cname="
set "ccount="
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
echo.
echo =============
echo.
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>: !VMowa!
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼: !VMpath!
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMname!
echo. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMcount!
echo.
echo =============
for /l %%a in (1,1,!VMcount!) do (
echo.
echo <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMname!%%a
cd OVFTool
ovftool --name=!VMname!%%a !VMowa! !VMpath!
cd ..
echo <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMname!%%a
vmrun -T ws start !VMpath!\!VMname!%%a\!VMname!%%a.vmx
)
goto wait
:delete
echo<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
set is=no
set /p is=ȷ<EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>ô?(yes/no, Ĭ<EFBFBD><EFBFBD>:%is%):
if "%is%" NEQ "yes" (
echo <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>
goto wait
)
echo <EFBFBD>ر<EFBFBD>vmware
taskkill /f /t /im vmware.exe
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo ɾ<EFBFBD><EFBFBD>: !name!
vmrun -T ws stop !VMpath!\!name!\!name!.vmx nogui
vmrun deleteVM !VMpath!\!name!\!name!.vmx nogui
)
goto wait
:snapshot
echo [<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
set /p VMSnapshot=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMSnapshot%):
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo !name!
vmrun -T ws stop !VMpath!\!name!\!name!.vmx nogui
vmrun -T ws snapshot !VMpath!\!name!\!name!.vmx !VMSnapshot! nogui
vmrun -T ws start !VMpath!\!VMname!%%a\!VMname!%%a.vmx nogui
)
goto wait
:delsnapshot
echo<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...]
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
set /p VMSnapshot=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMSnapshot%):
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo !name!
vmrun -T ws deleteSnapshot !VMpath!\!name!\!name!.vmx !VMSnapshot!
)
goto wait
:setip
echo [<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ip<EFBFBD><EFBFBD>ַ...]
set /p VMname=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMname%):
set /p VMcount=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMcount%):
set /p VMuser=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMuser%):
set /p VMpass=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%VMpass%):
set /p VMipStart=<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ip<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>:%VMipStart%):
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
set /a num=%VMipStart%+%%a-1
set ip=!VMnetwork!.!num!
echo !name!:!ip!
vmrun -T ws -gu !VMuser! -gp !VMpass! runProgramInGuest !VMpath!\!name!\!name!.vmx -noWait /bin/bash -c "echo 'node!num!' > /etc/hostname && echo '127.0.0.1 node!num!' >> /etc/hosts; sudo sed -i 's/IPADDR=.*$/IPADDR="!ip!"/g' /etc/sysconfig/network-scripts/ifcfg-e* || sudo sed -i 's/address .*$/address !ip!/g' /etc/network/interfaces; init 6" nogui
)
goto wait
:exit
echo <EFBFBD>˳<EFBFBD>...
ping /n 5 127.1>nul
5 years ago
exit