查看: 9625|回复: 10
收起左侧

[求助] 请教几个vmware软件命令行的命令

[复制链接]
songlynn
发表于 2013-11-6 14:53:58 | 显示全部楼层 |阅读模式
记得vmware有个vmrun的命令
但是一般的操作我基本上都会了
但是现在有个问题是
1如何用命令行克隆一个虚拟机(已做好快照,并需要以链接形式克隆)
2如何用命令行设置这个克隆好的虚拟机的硬盘为非持久的状态
3如何用命令行实现虚拟机的单个顺序启动(如果可以,多个顺序启动也行)
      例:有 0,1,……9 共10个虚拟机,每个虚拟机内置有自动关机命令,且各虚拟机从启动到关机时间不同,如何让虚拟机0启动后,等到它内置的自动关机命令把0这个虚拟机关闭后,马上启动1这个虚拟机,以此类推,直到所有虚拟机都启动一次,并自动关闭

THANK everyone~!
lzp4881
发表于 2013-11-29 14:19:35 | 显示全部楼层
什么叫硬盘的非持久状态?
songlynn
 楼主| 发表于 2013-12-16 10:42:52 | 显示全部楼层
lzp4881 发表于 2013-11-29 14:19
什么叫硬盘的非持久状态?

非持久状态,就是虚拟机的这个硬盘一直处于初始状态,开机后做的一切操作都无法保存,类是全硬盘影子系统
hnhk83361888
发表于 2013-12-23 11:19:43 | 显示全部楼层
看来没人懂?专家在哪里?
kavb15
发表于 2013-12-27 18:32:50 | 显示全部楼层
vmrun /?
kavb15
发表于 2013-12-27 18:36:40 | 显示全部楼层
@echo off
REM vmrun /?
REM 确保链接克隆的虚拟机硬盘未设置独立模式
set /a n=0
set /a max=10
set /a shijian=7
set VMPATH=C:\VMWARE\
set VMTXT=D:\vmstatus.txt
echo %VMWARE%
pause
set path=%path%;%VMPATH%;
vmrun list >%VMTXT%
for /f "tokens=4,* delims= " %%i in (%VMTXT%) do set num=%%i
if  %num% gtr 0 goto XH else goto START

:XH
ping -n %shijian% 127.0.0.1>nul
vmrun list >%VMTXT%
for /f "tokens=4,* delims= " %%i in (%VMTXT%) do set num=%%i
if  %num% gtr 0 goto XH else goto START
:START
G:\Workstation\vmrun clone   "D:\example\example.vmx" "D:\TEST\%n%\%n%.vmx" linked "Snapshot 1">nul
find "independent-nonpersistent" "D:\TEST\%n%\%n%.vmx" >nul
IF %errorlevel%==1 GOTO EDIT
IF %errorlevel%==0 GOTO RUNING


:EDIT
setlocal enabledelayedexpansion
set file="D:\TEST\%n%\%n%.vmx"
set "file=%file:"=%"
for %%i in ("%file%") do set file=%%~fi
set replaced=persistent
echo.
set all=independent-nonpersistent
for /f "delims=" %%i in ('type "%file%"') do (
    set str=%%i
    set "str=!str:%replaced%=%all%!"
    echo !str!>>"%file%"_tmp.vmx

)
rem copy "%file%" "%file%"_bak.vmx >nul 2>nul
move "%file%"_tmp.vmx "%file%" >nul 2>nul


:RUNING
echo                       虚拟机%n%启动  
vmrun start "D:\TEST\TEST\%n%\%n%.vmx"
set /a n+=1
if %n% lss %max% goto XH

:STOP
ping -n %shijian% 127.0.0.1>nul
vmrun list >%VMTXT%
for /f "tokens=4,* delims= " %%i in (%VMTXT%) do set num=%%i
if  %num% gtr 0 goto STOP
rd /q /s D:\TEST\
echo 执行完毕
pause
kavb15
发表于 2013-12-27 18:39:08 | 显示全部楼层
@echo off
REM vmrun /?
REM 确保链接克隆的虚拟机硬盘未设置独立模式
set /a n=0
set /a max=10
set /a shijian=7
set VMPATH=C:\VMWARE\
set VMTXT=D:\vmstatus.txt

set path=%path%;%VMPATH%;
vmrun list >%VMTXT%
for /f "tokens=4,* delims= " %%i in (%VMTXT%) do set num=%%i
if  %num% gtr 0 goto XH else goto START

:XH
ping -n %shijian% 127.0.0.1>nul
vmrun list >%VMTXT%
for /f "tokens=4,* delims= " %%i in (%VMTXT%) do set num=%%i
if  %num% gtr 0 goto XH else goto START
:START
G:\Workstation\vmrun clone   "D:\example\example.vmx" "D:\TEST\%n%\%n%.vmx" linked "Snapshot 1">nul
find "independent-nonpersistent" "D:\TEST\%n%\%n%.vmx" >nul
IF %errorlevel%==1 GOTO EDIT
IF %errorlevel%==0 GOTO RUNING


:EDIT
setlocal enabledelayedexpansion
set file="D:\TEST\%n%\%n%.vmx"
set "file=%file:"=%"
for %%i in ("%file%") do set file=%%~fi
set replaced=persistent
echo.
set all=independent-nonpersistent
for /f "delims=" %%i in ('type "%file%"') do (
    set str=%%i
    set "str=!str:%replaced%=%all%!"
    echo !str!>>"%file%"_tmp.vmx

)
rem copy "%file%" "%file%"_bak.vmx >nul 2>nul
move "%file%"_tmp.vmx "%file%" >nul 2>nul


:RUNING
echo                       虚拟机%n%启动  
vmrun start "D:\TEST\TEST\%n%\%n%.vmx"
set /a n+=1
if %n% lss %max% goto XH

:STOP
ping -n %shijian% 127.0.0.1>nul
vmrun list >%VMTXT%
for /f "tokens=4,* delims= " %%i in (%VMTXT%) do set num=%%i
if  %num% gtr 0 goto STOP
rd /q /s D:\TEST\
echo 执行完毕
pause
kavb15
发表于 2013-12-27 18:45:29 | 显示全部楼层
@echo off
REM vmrun /?
REM 确保链接克隆的虚拟机硬盘未设置独立模式
set /a n=0
set /a max=10
set /a shijian=7
set VMPATH=C:\VMWARE\
set VMTXT=D:\vmstatus.txt

set path=%path%;%VMPATH%;
vmrun list >%VMTXT%
for /f "tokens=4,* delims= " %%i in (%VMTXT%) do set num=%%i
if  %num% gtr 0 goto XH else goto START

:XH
ping -n %shijian% 127.0.0.1>nul
vmrun list >%VMTXT%
for /f "tokens=4,* delims= " %%i in (%VMTXT%) do set num=%%i
if  %num% gtr 0 goto XH else goto START
:START
vmrun clone   "D:\example\example.vmx" "D:\TEST\%n%\%n%.vmx" linked "Snapshot 1">nul
find "independent-nonpersistent" "D:\TEST\%n%\%n%.vmx" >nul
IF %errorlevel%==1 GOTO EDIT
IF %errorlevel%==0 GOTO RUNING


:EDIT
setlocal enabledelayedexpansion
set file="D:\TEST\%n%\%n%.vmx"
set "file=%file:"=%"
for %%i in ("%file%") do set file=%%~fi
set replaced=persistent
echo.
set all=independent-nonpersistent
for /f "delims=" %%i in ('type "%file%"') do (
    set str=%%i
    set "str=!str:%replaced%=%all%!"
    echo !str!>>"%file%"_tmp.vmx

)
rem copy "%file%" "%file%"_bak.vmx >nul 2>nul
move "%file%"_tmp.vmx "%file%" >nul 2>nul


:RUNING
echo                       虚拟机%n%启动  
vmrun start "D:\TEST\%n%\%n%.vmx"
set /a n+=1
if %n% lss %max% goto XH

:STOP
ping -n %shijian% 127.0.0.1>nul
vmrun list >%VMTXT%
for /f "tokens=4,* delims= " %%i in (%VMTXT%) do set num=%%i
if  %num% gtr 0 goto STOP
rd /q /s D:\TEST\
echo 执行完毕
pause


抱歉了,无法编辑,刷屏了。试试最后一个看能行不。或者直接根据 vmrun 提供的接口编写。
timepast
发表于 2014-1-1 10:59:24 | 显示全部楼层
kavb15 发表于 2013-12-27 18:45
@echo off
REM vmrun /?
REM 确保链接克隆的虚拟机硬盘未设置独立模式

使用的ones的精简版9.0.2 vmrun 报错
Unable to connect to host.
Error: Cannot find support libraries; Vix appears to have not been installed
加入vix组建文件夹   并且 注册dll  还是不行,求解决办法
gggccc
发表于 2014-1-6 06:58:38 | 显示全部楼层
你装下完整版不行么,库之类的支持多半被精简掉了啊,貌似精简版网络部分多半也精简了的
您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

手机版|杀毒软件|软件论坛| 卡饭论坛

Copyright © KaFan  KaFan.cn All Rights Reserved.

Powered by Discuz! X3.4( 沪ICP备2020031077号-2 ) GMT+8, 2024-11-23 01:02 , Processed in 0.127110 second(s), 16 queries .

卡饭网所发布的一切软件、样本、工具、文章等仅限用于学习和研究,不得将上述内容用于商业或者其他非法用途,否则产生的一切后果自负,本站信息来自网络,版权争议问题与本站无关,您必须在下载后的24小时之内从您的电脑中彻底删除上述信息,如有问题请通过邮件与我们联系。

快速回复 客服 返回顶部 返回列表