vmrun.exe存在多个问题

时间:2012-02-16 06:10:32

标签: windows batch-file automation vmware

主机:带有VMWare Workstation 7.1的Windows 7 pro 64位

我想要实现自动化:

1) Clone a template into a new VM. The template is Windows Server 2003 32-bit w/SP1 and already has VMWare tools installed and network and VM settings configured the way I want.
2) Start the VM
3) Copy a batch file and a zip file into the VM which installs a build and copies some files into certain locations. The build is different each time but I want the OS to be the same each time.
4) Run the batch file within the VM

基本思想是能够将不同版本的构建部署到具有受控操作系统映像和配置的VM中。

我的批处理文件类似于:

     vmrun clone %vm_template_path% %new_vm_path% full
     vmrun -T ws -gu <user> -gp <pass> start %new_vm_path% gui
     vmrun -T ws -gu <user> -gp <pass> copyFileFromHostToGuest %new_vm_path% %file_on_host% %file_path_on_VM%
     vmrun -T ws -gu <user> -gp <pass> runProgramInGuest %new_vm_%path% -nowait -interactive %file_on_host%

克隆工作得很好。我的问题是: 1)start命令正确启动VM,但从不返回到批处理文件中的下一行。我等了30多分钟才确保。 2)copyFileFromHostToGuest不复制文件,永远不会返回或显示任何错误。它只是坐在那里。我试图复制的文件是30KB,我等了15分钟左右。

2 个答案:

答案 0 :(得分:1)

看起来您的问题可能是在VM打开的整个时间内启动命令处于活动状态。您是否尝试在单独的批处理文件中调用它?

vmrun clone %vm_template_path% %new_vm_path% full

REM Creates a separate batch to run the start command which will delete itself when done
ECHO vmrun -T ws -gu <user> -gp <pass> start %new_vm_path% gui > startVM.bat
ECHO del /q /s /f startVM.bat >> startVM.bat

REM runs the separate batch
startVM.bat

REM if the VM needs to be booted before you continue with the file copy you can try a TIMEOUT in here like the two minute one below:
TIMEOUT 120

vmrun -T ws -gu <user> -gp <pass> copyFileFromHostToGuest %new_vm_path% %file_on_host% %file_path_on_VM%
vmrun -T ws -gu <user> -gp <pass> runProgramInGuest %new_vm_%path% -nowait -interactive %file_on_host%

答案 1 :(得分:0)

您是否在使用32位Windows作为主机操作系统的计算机上尝试过? 我遇到了同样的问题,在打开一个支持案例后发现了很多错误,结果发现Panda Antivirus在阻止VMRun的64位窗口上出现了问题。所以我要么改变防病毒软件,要么使用32位Windows。