windows - vmrun.exe 的多个问题

标签 windows batch-file automation vmware

主机:带有 VMWare Workstation 7.1 的 Windows 7 专业版 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 分钟左右。

最佳答案

看起来您的问题可能是启动命令在虚拟机启动的整个过程中处于事件状态。您是否尝试过在单独的批处理文件中调用它?

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%

关于windows - vmrun.exe 的多个问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9306401/

相关文章:

windows - 用于将 psql 查询输出存储到变量中的批处理文件

file - 连接文件 - 包括文件夹中的文件

sql - sqlcmd错误处理

ruby - 使用 watir-webdriver 选择本地文件

python - 在 Python 中可靠地检测 Windows

windows - 如何在Visual Studio 2010中快速切换窗口布局?

windows - Apache 代理 - HTTP 到 HTTPS

windows - 如何使用需要特定文件名的 CLI 工具在批处理脚本中使用通配符?

python - Anaconda Python 32 位正在尝试加载 Anaconda 64 位库

perl - 如何使用OLE模块处理Excel?