I know this article is very old, but I stumbled acoss it.
The reason is: I was messing with packer and hyper-v in my homelab and did not have a solution for the same problem.
I had the following situation:
Packer appeared to be to slow for hitting the button in time.
I looked into making better images with dism, trying to deactivate the message and stuff. However, the solution was more simple:
The solution was for me: Set “boot wait to -1 second.” This will avoid the wait time, as described in the docs from the hyper-v.
Now the machine will give the command in time.
source "hyperv-iso" "windows-server-2022" {
boot_command = ["f u n w i t h p a c k e r"]
boot_wait = "-1s" #Set to -1s to disable waiting for the boot menu - This may trick the "press any key to boot from dvd"
#I this example I am loading the autounatteneded.xml via secondary iso:
secondary_iso_images = [
"./answer.iso"
]
iso_url = "file://D:/VM/ISO/WS2022_SERVER_EVAL_x64FRE_en-us.iso"
first_boot_device = "DVD"
the actual boot command does not really madder. I just want to have fun with packer ![]()
Autounattend takes over headless. If you have something displaying there, than you may not frog around with the command and be a little serious.
Hopefully it helps somebody else who stumbles across this question.