github.com/hashicorp/packer@v1.14.3/website/content/guides/automatic-operating-system-installs/autounattend_windows.mdx (about) 1 --- 2 page_title: Unattended Windows Installation 3 description: |- 4 Learn how to use an autounattend file to automatically answer installation 5 questions and enable Packer to connect to your Windows instance. 6 --- 7 8 # Unattended Installation for Windows 9 10 Unattended Windows installation is done via "Answer Files", or "Unattend files". 11 12 These files are generally named "autounattend.xml". They are not 13 Packer-specific tools, though we do make use of them. 14 15 If, after following this guide, you're still having issues getting an answer 16 file working, We recommend you read the official documentation on 17 [answer files](https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/update-windows-settings-and-scripts-create-your-own-answer-file-sxs). 18 19 The guide here is hopefully enough to get you started, but isn't a replacement 20 for the official documentation. 21 22 ## When To Use an Answer File 23 24 If you are installing the Windows Operating System from a mounted iso as part of 25 your Packer build, you will need to use an Answer file. For example, you're 26 building an image from scratch using the [vmware-iso](/packer/plugins/builders/vmware/iso), 27 [virtualbox-iso](/packer/plugins/builders/virtualbox/iso), or 28 [hyperv-iso](/packer/plugins/builders/hyperv/iso) builders. 29 30 If you are not installing the operating system, you won't need to provide an 31 answer file. If you are using a pre-built image 32 in a cloud, you don't need to worry about Answer files. 33 34 ## How to make an Answer File 35 36 You can either start from an example answer file from a known repo (take a look 37 at the examples links below), or you can generate one using an answer file 38 wizard by selecting New File > New Answer file on a Windows machine. 39 A comprehensive list of all the options you can set in an answer file can be 40 found [here](https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/components-b-unattend) 41 42 ## Where to put the Answer File 43 44 Windows will automatically look for an autounattend.xml file on mounted drives. 45 Many users use the `floppy_files` option or a secondary mounted iso for 46 providing the answer file to their iso builders. 47 48 You can also specify an unattend file to use by using the /unattend: option when 49 running Windows Setup (setup.exe) in your `boot_command`. 50 51 ## What does Packer _need_ the Answer File to do? 52 53 Packer needs the Answer File to handle any questions that would normally be 54 answered interactively during a Windows installation. 55 56 If you want to be able to use provisioners, the Answer file must also contain 57 a script that sets up SSH or WinRM so that Packer can connect to the instance. 58 59 Finally, your Packer build will be much smoother if the Answer File handles or 60 disables Windows updates rather than you trying to run them using a Packer 61 provisioner. This is because the winrm communicator does not handle the 62 disconnects caused by automatic reboots in Windows updates well, and the 63 disconnections can fail a build. 64 65 ## Examples 66 67 The chef-maintained bento boxes are a great example of a Windows build that 68 sets up openssh as part of the unattended installation so that Packer can 69 connect using the SSH communicator. The functioning answer files for every 70 modern Windows version can be found [here](https://github.com/chef/bento/tree/master/packer_templates/win_answer_files). 71 72 Stefan Scherer's [packer-windows repo](https://github.com/StefanScherer/packer-windows) 73 is a great example of Windows builds that set up WinRM as part of the unattended 74 installation so that Packer can connect using the `winrm` communicator: 75 76 ```json 77 { 78 "type": "virtualbox-iso", 79 "guest_os_type": "Windows2008_64", 80 "iso_url": "https://download.microsoft.com/download/7/5/E/75EC4E54-5B02-42D6-8879-D8D3A25FBEF7/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso", 81 "iso_checksum": "sha256:30832AD76CCFA4CE48CCB936EDEFE02079D42FB1DA32201BF9E3A880C8ED6312", 82 "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c Packer_Provisioning_Shutdown", 83 "guest_additions_mode": "attach", 84 "floppy_files": ["./scripts/Autounattend.xml", "./scripts/openssh.ps1"], 85 "communicator": "winrm", 86 "winrm_username": "vagrant", 87 "winrm_password": "vagrant" 88 } 89 ```