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.

Tags: , , , ,

  1. Wayne’s avatar

    I’ve been using this for sometime – modification of the sysprep files, etc. I insert some files of my own at the end of the build. Any idea how to do this in VC2.5? It appears they changed some things…

  2. memey’s avatar

    I want to make an image with my OS. i use sysprep. Can i determine the IP address and ptinter setting in sysprep?? (before install and image in new PC, we must enter IP address and wich printer are use?) tahnk youu

    * can i receive the answer to email??

  3. slowe’s avatar

    Wayne,

    Sorry, I should have responded sooner to your comment. I haven’t yet figured out how to do this in VC2.5, either. Still working on that one!

    Memey,

    There are better resources out there than this site for questions relating specifically to Sysprep. Have a look at this Google search for some pertinent sites:

    http://www.google.com/search?hl=en&q=how+to+use+sysprep

    Hope this helps!

  4. Raymond Brighenti’s avatar

    Hi Scott,

    Anything further to how to do this with 2.5?

    Thanks

    Ray

  5. slowe’s avatar

    Raymond,

    Unfortunately, I have no new information to share. I’ll post an update as soon as I make any progress.

  6. Raymond Brighenti’s avatar

    Hi,

    So I found the Customisation Specification Manager (what a mouthfull!)
    You can add sysprep settings but then the only things Virtual center will then customize is Network and SID.

    The thing I like is when you create a VM VC can name the machine the same name, but adding the sysprep breaks it… ehhh

    Feature request maybe :)

    Ray

  7. Raymond Brighenti’s avatar

    Should say

    The thing I like is when you create a VM using VC customisation is, it can name the machine in windows the same name you’ve spec’d for VC.

    Adding the extra sysprep details breaks this.