|
|
|
|
@echo off
|
|
|
|
|
Setlocal enabledelayedexpansion
|
|
|
|
|
::CODER BY lework
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
::<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
::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 <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> 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
|
|
|
|
|
|
|
|
|
|
: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
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: !VMname!%%a
|
|
|
|
|
vmrun -T ws start !VMpath!\!VMname!%%a\!VMname!%%a.vmx
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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 /bin/bash -c "sudo sed -i 's/^IPADDR=.*/IPADDR=!ip!/g' /etc/sysconfig/network-scripts/ifcfg-ens33;/etc/init.d/network restart || sudo sed -i 's/^address.*$/address !ip!/g' /etc/network/interfaces;/etc/init.d/network restart" nogui
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
: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 /bin/bash -c "sudo sed -i 's/^IPADDR=.*/IPADDR=!ip!/g' /etc/sysconfig/network-scripts/ifcfg-ens33;/etc/init.d/network restart || sudo sed -i 's/^address.*$/address !ip!/g' /etc/network/interfaces;/etc/init.d/network restart" nogui
|
|
|
|
|
)
|
|
|
|
|
goto wait
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:exit
|
|
|
|
|
echo <EFBFBD>˳<EFBFBD>...
|
|
|
|
|
ping /n 5 127.1>nul
|
|
|
|
|
exit
|