Virtual Geek

Tales from real IT system administrators world and non-production environment

Inject and install VMware Tools During Install by modifying Microsoft Windows ISO

I wrote this article as a first part of a Configuring and creating VMWare virtual machine template using HashiCorp Packer.exe. While automating and installing unattended Microsoft Windows VM template on VMWare vCenter Server using packer I was facing few challenges such as it was getting stuck and freeze on Waiting for IP. It was not moving beyond IP point. It happens because VMware Tools are not installed. To resolve this issue I had to inject or slipstream VMWare tools inside Microsoft Windows Server OS ISO file, Which will automatically install it once OS installation is completed. 

Part 1: Inject and install VMware Tools During Install by modifying Microsoft Windows ISO
Part 2: Configure IIS server to allow download .ISO files
Part 3: Using HashiCorp Packer to build a Windows Server VM template for VMware vSphere

As a first step I have downloaded Microsoft Windows Server ISO from It is an evaluation ISO copy.

Microsoft Windows server 2022 ISO VHD download evaluation packer devops infrastracture as a code IAAS hashicorp terraform vault.png

Right click downloaded Windows OS ISO file and click Mount. Next Open the selected file.

Microsoft Windows server 2022 ISO VHD download evaluation packer devops infrastracture as a code IAAS hashicorp terraform vault mount vmware template open.png

Open PowerShell as an Administrator. Run below two commands to create 2 folders ExtractedISO and MountWim under C:\Temp directory on the system. Verify folders are created and Make note of folder name spellings.

mkdir C:\Temp\ExtractedISO -Force
mkdir C:\Temp\MountWim -Force

Microsoft Windows Iso Hashicorp Packer.exe modify inject slipstream VMware tools vmtools vmware vsphere automation VM creation template packer vcenter esxi script ISO.png

Next go to mounted drive of Windows OS Server ISO file under This PC. Expand mounted drive (In your case drive letter will be different). Inside Sources folder find file name install.wim and copy to C:\temp\ExtractedISO folder.

Microsoft Powershell Install.wim sources packer.exe deploy infrastructure as a code VMware vsphere vcenter esxi vm template virtual machine automation creation autodeploy.xml unattended install mount.png

If incase PowerShell is closed. Open it with as an Administrator again. and type below command to view available edition flavors of Windows OS such as standard or datacenter (Desktop experience GUI). 

I will use dism.exe. DISM is Deployment Image Servicing and Management tool. Deployment Image Servicing and Management (DISM) is a command-line tool utility that is used to service/modify Windows images. You can use DISM image management commands to mount and get information about Windows image (.wim) files and modify it, Full-flash utility (FFU) files, or virtual hard disks (VHD).

dism /Get-ImageInfo /ImageFile:C:\Temp\ExtractedISO\install.wim

I have 4 editions available in current Windows Server ISO, I am going to use last index 4 in next command, which is Windows Server 2022 Datacenter Evaluation (Desktop Experience). Make sure your command always ends with the operation completed successfully.

Microsoft Windows Powershell administrator dism get-imageinfo imagefile install.wim boot.wim index 2022 datacenter evaluation desktop expireance packer hashicorp deployment image servicing and management tool mount.png

In the following command mount copied install.vim file under folder C:\temp\ExtractedISO under directory C:\temp/MountWim with below command.

dism /Mount-Image /ImageFile:C:\temp\ExtractedISO\install.wim /mountdir:c:\temp\MountWim /Index:4

Once install.wim is mounted you can view the folder structure under MountWim folder. This resembles to the same folder structure of Windows on C drive. Here mounting image is succeeded in the end. 

dism mount-image imagefile install.wim sources mount dir index packer microsoft windows os create iso slipstream hashicorp vmware tools vmtools vsphere vcenter esxi vcsa deployment image servicing and mangement tool successfully.png

Go to This PC drives, right click the DVD ISO image mounted earlier. Right click on it and click Eject to unmount OS ISO file.

Microsoft Windows OS iso mount 2022 eject hashicorp packer.exe create vmware vsphere vCenter vcsa template virtual machine vm esxi dvd cd automation terraform create vm.png

Download latest VMware Tools from VMware Customer Connect Website You can either download zip or ISO file. Extract exe file, in my case I am using 64 bit executable exe file. (In the ISO file there is Setup64.exe file, which you can use). Create a new folder structure as like C:\Temp\MountWim\Temp\vmtools.

VMware Customer connect download Vmware tools packages for windows Packer.exe create template for windows OS extract setup64 zip vsphere vcenter cloud hashicorp packer.png

Extract/Copy exe file under C:\temp\MountWim\Temp\vmtools as shown below.

Hashicorp packer vmware tools vmtools mount vim windows setup scripts completesetup.cmd vmware vcenter vsphere vcsa esxi virtual machine template vmtx creation packer.png

Following step is very crucial and has to be very accurate. Cmd script file name has to be same. I have created a folder and file under C:\temp\MountWim\Windows\Setup\Scripts\SetupComplete.cmd. SetupComplete.cmd content has to be as below. Check VMWare Tools exe file name and modify your script and tools version accordingly.

:: Install VMware Tools application using script
C:\Temp\vmtools\VMware-tools-12.2.0-21223074-x86_64.exe /S /v "/qn REBOOT=R ADDLOCAL=ALL"

:: Remove C:\temp\vmtools directory
rmdir C:\Temp\vmtools /s /q

:: Remove C:\Windows\Setup\Scripts folder
rmdir C:\Windows\Setup\Scripts /s /q
  • %WINDIR%\Setup\Scripts\SetupComplete.cmd: This script runs with local system permissions and starts immediately after the user sees the desktop. This setting is disabled when using OEM product keys, except on Enterprise editions and Windows Server operating systems.
  • %WINDIR%\Setup\Scripts\ErrorHandler.cmd: This script runs automatically when Setup encounters a fatal error. It runs with local system permission.

Above script will install VMware Tools in an unattended mode once Windows Operating system installation is completed and will remove directory and its content from C:\Temp\vmtools and C:\windows\setup\script which is not required once the installation is completed and finished.

Vmware vSphere vCenter ESxi Template virtual machine automation windows setup Script setupcomplete.cmd slipstream inject auto install vmware tools hashicorp packer.png

New setup is ready with newly modified install.wim, Unmount the install.wim mounted folder using below command. 

dism /Unmount-Image /mountdir:c:\temp\MountWim /commit /CheckIntegrity

This is ready for 4th index only inside install.wim. If you are planning to use other editions, you will need repeat same steps to configure other indexes (editions) one by one furthermore.

disk unmount-image mountdir install.vim sources commit checkintegrity deployment image servicing and management tool vmware vsphere template creation with packer hashicorp vmtx vmware vCenter vcsa.png

My install.wim is modified and ready. To inject this install.wim in Windows Server ISO file you can use your choice of ISO application. I am using PowerISO here to replace Install.Wim inside /sources and modify my Windows Server ISO file. I have installed PowerISO on my system.

PowerISO UltraISO bootable Image download Microsoft Windows Server 2022 ISO slipstream inject vmware tools vmtools install.wim boot.wim mount Hashicorp packer.exe create vmware template on vcenter server.png

Open Windows server OS ISO file in PowerISO application.

Microsoft Windows Server ISO PowerISO evaluation Hashicorp packer hcl configuration vmware vsphere vCenter ESXi Virtual machine template vmtx create template vm automation as a code infrastructure.png

Drag and drop install.wim file inside /sources folder on PowerISO. It shows the message that the file and folder name already exists. Do you want to overwrite it? Verify the summary what will replace with what and click Yes.

Hashicorp hcl packer.exe deploy vmware vsphere vCenter template esxi configuration vcsa poweriso replace install.vim boot.vim dvd sources configuration installation automation unattended vmware tools installation inject.png

Go to File Menu, from drop down click Save as option. Provide a new name to new ISO file and save.

Microsoft Vmware vSPhere vCenter template creation modified windows 2022 Server ISO hashicorp packer.exe terraform.exe hcl language automation infrastructure as a code.png

It is time to test the New ISO. I have used it on VMware Virtual Machine Console connecting/mounting ISO and Installed OS. After Installation all looks good VMware Tools are installed with the OS.

Vmware vSphere vCenter Esxi vcsa virtual machine virtualization vm automation installtion vmware tools vmtools modify windows server 2022 microsoft remote console packer hashicorp waiting for IP.png

If incase you want to use free version of ISO, You can use imgBurn. you need to download and install ImgBurn.

  1. Open ImgBurn and choose the option "Create image file from files/folders."
  2. Go to the Advanced tab and click on the Bootable Disc option.
  3. Locate the Source box and click on the browse icon. Find the folder containing the extracted ISO file and the additional files you want to add.
  4. Select a destination to save the new bootable ISO file by clicking the browse icon next to the Destination box. Choose a location and provide a name for the ISO file.
  5. In the Bootable Disc tab, choose the option "Make Image Bootable." Set the Emulation type as None (Custom) and enter 8 (or 4 for Vista ISO) in the Sectors To Load box.
  6. Locate the Boot Image box and click on the browse icon. Navigate to the Boot folder within the newly created folder and select the file named Click Open.
  7. Click the Build button to start building the bootable ISO image file. When prompted, click Yes or OK in the dialog boxes to proceed.
  8. After the process is complete, you will have two ISO files. Upload the one that has the proper size, not the smaller one.
  9. Mount the ISO file to a virtual machine and test the installation of each option to ensure they all work correctly.
  10. If everything is functioning as expected, you're done!

Useful Articles
Deploy install VCSA (vCenter server appliance 6.5) on VMWare Workstation
Enable or disable SSH on VMWare vCenter Server Appliance (VCSA)
The top 10 reasons to upgrade to VMware vSphere 6.5
vCenter server appliance 6.5 deployment Error The supplied system is not valid
How to deploy vCenter server appliance on VMware Workstation
Enable Access to the VCSA Bash shell or Appliance Shell
Patching the vCenter Server Appliance VCSA
Install and Configure VMware UMDS on Linux
How to Install vCenter server appliance on ESXi host

Go Back


Blog Search

Page Views


Follow me on Blogarama