Scott's Weblog The weblog of an IT pro focusing on cloud computing, Kubernetes, Linux, containers, and networking

Customizing the Sysprep.inf Created by VirtualCenter

The support that VMware VirtualCenter provides for using Sysprep to clone Windows virtual machines (VMs) is a key part of VMware’s quick provisioning functionality. While VirtualCenter provides a means for creating unattended answer files (via Customization Specifications), it does not provide a way to allow users to customize the Sysprep.inf that is generated by VirtualCenter. Of course, that is not to say that such customization isn’t possible, just that there isn’t a pretty graphical interface provided for it. Fortunately, the process for customizing the Sysprep.inf isn’t too terribly difficult.

Using information provided by this Virtrix post, I managed to customize the Sysprep.inf. A recent Virtual Desktop Infrastructure (VDI) project on which I was working called for VMs to have small Windows pagefiles, but Sysprep kept resetting the pagefile size to the default. In this case, the default was much larger than the customer desired, so we needed a way to tell Sysprep not to resize the pagefile.

The first step in customize the Sysprep.inf is to decode the VBScript files used by VirtualCenter. This script decoder works wonderfully, producing unencoded script files that can be easily edited. Be sure to backup the original files first in the event you run into a problem! Here’s the commands I used to decode the scripts, which are located in C:\Program Files\VMware\VMware VirtualCenter 2.0\scripts:

move autoprep.wsf autoprep.wsf.backup  
move gensysprepinf.vbs gensysprepinf.vbs.backup  
scrdec18 autoprep.wsf.backup autoprep.wsf  
scrdec18 gensysprepinf.vbs.backup gensysprepinf.vbs

First, I moved the originals to a backup file, then used the backup file as the source for decoding to a new file with the original name.

Once the files are decoded, you can then edit gensysprepinf.vbs to add or remove entries from the Sysprep.inf that is generated by VirtualCenter. In Vincent’s example, he had to modify the default regional settings; in my case, I needed to change the behavior of Sysprep with regards to the pagefile. I modified the following section:

outStr = "[Unattended]" & vbCrLf _  
& "   OemSkipEula=Yes" & vbCrLf _  
& "   InstallFilesPath=\sysprep\i386" & vbCrLf _  
& "   KeepPageFile=1" & vbCrLf _`

That last line “KeepPageFile=1”, was what I added to tell Sysprep to leave the existing pagefile alone. That line isn’t perfect, though; this Microsoft KB article describes how it works. In our case, it was enough.

Once that’s done, I had to edit autoprep.wsf to indicate that the gensysprepinf.vbs file is no longer encoded. I had to edit the line that referenced gensysprepinf.vbs:

<script language="VBScript" src="gensysprepinf.vbs">

The key change here is from “VBScript.Encode” to “VBScript” for the language parameter. This is detailed in Vincent’s post as well. That’s it! Of course, you could edit the scripts far more extensively, if so desired.

Thanks to Vincent for a great post; without his post, I wouldn’t have known where to start. It also looks like Jase McCarty used the same technique in extending the VM’s root partition; although I didn’t read his paper I would guess the same mechanisms are involved.

Metadata and Navigation

Be social and share this post!