我正在使用VBoxManage unattended install
并希望在安装后运行脚本来自动创建 VM,这让我--post-install-command
选择了。这里的问题是:我的脚本中的下一步需要Guest Additions,所以我--install-additions
在安装中使用了选项。不幸的是,这个选项在安装 Guest Additions 后不会重新启动机器,所以我正在寻找一种解决方法,所以我重新启动 VM(从主机或来宾),然后继续我的主脚本。
问问题
299 次
1 回答
1
不幸的是,我没有发现 VBox 在 VM 启动时触发的任何事件,所以我不得不等待它完全启动。
完全启动平均需要 2-3 分钟,所以我使用了 3 分钟的计时器。
$postInstallCommands = 'VBoxControl guestproperty set installation_finished y && (shutdown /s || shutdown -P now)'
########## Initiate unattended installation
VBoxManage unattended install "$vmName" `
--iso="$isoFile" `
--user="$userName" `
--password="$password" `
--full-user-name="$userName" `
--install-additions `
--locale=en_US `
--country=US `
--time-zone=EST `
--image-index=1 `
--post-install-command="$postInstallCommands" *> $null
########## Start VM and wait to finish install
VBoxManage startvm "$vmName" --type headless
Write-Host "Waiting for VM to finish OS installation..."
VBoxManage guestproperty wait "$vmName" installation_finished *> $null
Start-Sleep -s 180
于 2021-03-03T08:20:18.047 回答