For the past couple of years i have tried just about every type of method to deploy custom settings in an unattended install. Batch files, .reg files, .vbs files, hivexxx.inf files, security templates - you name it, i've tried it. Each method had it's own strenghts and advantages, but all were limited in what they could do. I finally settled on using inf files exclusively after researching what they could do. There's two primary reasons that attracked me to .inf files:
1 - Inf files can do everything but delete files/folders with wildcards. That's the only thing i've found that inf files won't do. In the past i've used a combination method, using batch and .reg files to deploy settings. With an inf file, i can do everything in one inf file, making things easier and simpler.
2 - There's a lot of documentation on other methods such as batch files and .reg files, but there's not much documentation on using an inf to deploy everything in an unattended install. In fact, none of the major websites i've seen even use inf files. Learning inf files presents a challenge to do something new and different. The knowledge you gain working with inf files can be used outside of unattended installs. In the IT field, knowing how to automate or script things is a real advantage. As someone as this forum recently said, and i paraphrase, "you will spend more time administering a network than writing scripts". So learning inf files will help you automate the unattended install, and help you in other areas too.
This document will help you understand and use .inf files in your unattended install. This document is meant for advanced users that are looking to make there unattended installs more powerful, quicker, and professional. If you are new to unattended installs i recommend using traditional methods such as batch files first, before exploring this option.
Inf files look complex but when you break them down they aren't. Let's look at a sample inf that deletes a registry key. I got this file from neowin or someplace else.
| ; Windows XP explorer movie fix. ; ; WARNING - Use this file at your own risk. ; ; Executing this file will remove a registry key which makes explorer load shmedia.dll. ; Simply put, this removes the annoying "permission denied" errors when trying to ; move/copy/delete AVI files. ; ; To use this fix, right-click on the file and select install. Done. [version] signature="$Windows NT$" [DefaultInstall] DelReg = Reduce.Reg [Reduce.Reg] HKLM, "SOFTWARE\Classes\CLSID\{87D62D94-71B3-4b9a-9489-5FE6850DC73E}\InProcServer32" |
All the inf does is delete a registry key. To run the inf, you can either right click on it and select Install, or you can run the command below.
rundll32 setupapi,InstallHinfSection Safe_to_disable_xp_pro 128 .\filename.inf
A good document that explains what that command means is
Internet Explorer 5.0 Resource Kit- Working with .inf Files . Note that it was written for win9x, which uses setupx.dll instead of setupapi.
Let me explain in detail why each line was needed:
| [version] signature="$Windows NT$" <--#1 [DefaultInstall] <--#2 DelReg = Reduce.Reg <--#3 [Reduce.Reg] HKLM, "SOFTWARE\Classes\CLSID\{87D62D94-71B3-4b9a-9489-5FE6850DC73E}\InProcServer32" <--#4 |
1 - Makes inf only work on NT/2000/XP/2003, to make cross platform use Signature=$CHICAGO$
2 - The defaultinstall section is run if you right click on the inf and select install. This section is optional but most infs you make you will want to be able to right click on.
3 - Under defaultinstall you list what commands you want to do. Delreg will delete registry settings. The command is delreg=subsection. In this case the subsection is reduce.reg. Delreg will look at this section and delete any registry keys it finds. It doesn't matter what you name the subsection. You can call the subsection reduce.reg, or reduce.delreg, or thiswillbedeleted
4 - I will go into the syntax of commands next.
Back to top
Everytime you make an inf file, i recommend you use a template. That way, you have easy access to common settings. Here is what i recommand starting your inf off as. I recommand saving this as a template to use everytime you make an inf file.
template.inf
| [Version]
|
Everything that begins with a semi-colon will be ignored by setup. You can also put a semi-colon after a command. Here's a sample inf that has most of the commands.
sample.inf
| [Version] Signature=$CHICAGO$ [DefaultInstall]
[Install.Apps] [delete] [SourceDisksFiles]
[cleanup1]
[unreg] [StartCDInstall]
[resetdisk]
[Strings] Explorer = "Software\Microsoft\Windows\CurrentVersion\Explorer" |
As you can see I used strings or variables to save time typing and make it look more professional. Any variables you use need to be defined under [strings]. I recommend doing strings last.
The only hard part of making an .inf is understanding how to correctly format the line. The syntax of an AddReg section (install.apps above) is as follows:
MainRegistryKey,RegistryKey,Name,Type,Data
MainRegistryKey is listed above. Value can be
HKLM,HKCU,HKCR,HKU
RegistryKey is the main registry key.
Name is the section on the right hand side in regedit under the section Name.
Type is the type of registry data. Consult my Registry Data Types in template.inf. Usually you'll be dealing with dword's.Data is the value of the data. In regedit on the right hand side it's called Data. For a dword the value is usually a 0 or 1. For a reg_sz usually it's a string like "today is a good day".
For more information on each section see INF File Sections and Directives
Back to top
Integrating your inf file in xp setup
There are many ways to call your inf during the unattended setup. The first is cmdlines.txt. You'll want to make a folder called $OEM$. In this folder make a file called cmdlines.txt. In this file put what's below.
cmdlines.txt
|
[Commands] |
That example will run 3 .inf's during setup. In this example, the 3 .inf's are located in the $OEM$ folder. But let's say you want to put your inf file in the windows folder. What you would do is put your inf file (let's call it install.inf) in the $OEM$\$$ folder. $$ will map to %windir% during setup. In cmdlines.txt you would put this:
|
[Commands] |
The command will run the section called DefaultInstall in the file install.inf located in the %windir% folder
%10% maps to the %windir% directory. For a full list of variables see template.inf above.
128 tells setup to NOT restart if the inf needs to restart the
pc.
In your unattend file you'll probably want to have at least this:
|
[Unattended] |
2. GuiRunOnce and SetupParams.
These 2 commands are used in an unattend file. The syntax is below.
GuiRunOnce
|
[GUIRunOnce] |
For more information on GuiRunOnce see Configuring [GuiRunOnce] to Perform Tasks
SetupParams
|
[SetupParams] |
For more information on SetupParams see Use of the [SetupParams] Section in an Unattended Answer File
Another method is to use an already existing inf file.
For example, let's using the movie maker install file moviemk.inf. Delete \i386\moviemk.in_ from your local source. Rename your inf file to moviemk.inf and put it into i386 folder. Now when setup runs it'll run your inf file. This works because setup runs the DefaultInstall section of Moviemk.inf, as referenced in syssetup.inf's infs.always section. Below is XP's syssetup.inf infs.always section.
|
[Infs.Always] |
So if you didn't want to install media player's playlist, you would rename your inf file to mymusic.inf and rename your defaultinstall section to WMPLaylist. Syssetup is different for each os, and even service packs. You cannot directly edit syssetup.inf because it's digitally signed since windows 2000.
During the early point of setup the OC manager installs the optional componants. It uses sysoc.inf to build a list of files, then checks that list against your unattend file. The end result is used to determine what to install. You can edit sysoc.inf to tell setup to not install something, and you can use sysoc.inf to install something else.
For example, let's say you wanted to add system restore to the windows optional componants list. You would do the following:
Edit sysoc.inf and put the following:
|
[Version] |
Notice the bold line, that's new. Now edit sr.inf. You will find it in your inf folder, or expand it from the cd.
|
[version] |
Again, only what's in bold is new. You want to add the bold stuff to your sr.inf. Now you want to delete i386\sr.in_ from your local source and put your custom sr.inf into the i386 folder. Now after you install windows, system restore will be listed in Add/remove windows componants. The Modes= line tells OC Manager to install it.
If you want, you can probably remove a line from sysoc.inf that you don't want. I haven't tried this, but I hear it works. The reason i recommend this is because sysocmgr is very inefficient. When you run sysocmgr (usually by clicking on 'add/remove windows components'), it looks at every inf in sysoc.inf. Then if you change one thing - such as installign IIS - it processes every inf referenced in sysoc.inf. To see what i mean, delete every .log and .txt file in your windows folder, then run sysocmgr. Now go back to your windows folder, and you'll notice files like ocmsn.log. Removing bloat from sysoc.inf could speed up sysocmgr.
Another way to deploy infs is through txtsetup.sif, which actually builds the registry hives. More information is at Slipstreaming SP2 hotfixes without any batch files, It looks like Service Pack 2 . This method is a little bit more involved, but should work fine.
Back to top
Using an INF to install software
You can use an inf file to install software using RunOnce or RunOnceEx. Below is an inf that does this.
Install.apps.inf
|
[Version] [DefaultInstall] [Install.Apps] [Strings] RunOnceEx = "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx" |
So what this inf does is add entries to RunOnceEx to install my software. RunOnceEx is run when you restart the pc. If you run this inf via cmdlines.txt or svcpack.inf, the software will be installed once the user logs in for the first time. If you use the above inf in moviemk.inf or other inf files, they will run at the 13 min mark. Below is a picture of what you will see.

As a side note, if you use an inf during setup try to do stuff like registering files using RunOnce or RunOnceEx. Also try to avoid copying files. If an inf tries to copy files during setup the files will need to be digitally signed. I'm not talking about inf files that run in GuiRunOnce or cmdlines.txt, i'm talking about inf files that run using sysoc.inf or the infs in syssetup.inf.
Manually removing optional components
Optional components are installed via sysoc.inf. You can customize what optional components are installed by using the [components] section of an unattend file, or by manually editing sysoc.inf or one of it's sub infs. Windows XP's ref.chm gives a full list of documented switches, including what each switch does. Everything under [components] corresponds to an inf section of the same name. For example, rootautoupdate=off maps to rootau.inf, which is referenced in sysoc.inf.
rootau.inf
|
; ROOTAU.INF |
When setup reaches the optional components section of setup, it first builds a list of every [optional components] section referenced in sysoc.inf. Setup then compares this list to your [components] section in your unattend file, then installs whatever is left.
If you wanted to, you could manually edit sysoc.inf or the sub inf to prevent the optional component from being installed. For example if you didn't want the root update to be installed, you could put a semicolon in front of the line in sysoc.inf that says rootautoupdate, or you could remove the line entirely.
A full list of valid commands for the [components] section in the unattend file is listed below. These are for only XP pro, other OS' could have other switches. If you are unsure what a command does, search your inf folder to see what inf uses the command. If you are using ref.chm, look at the [components] section under unattend.txt, and look at NetOptionalComponents under Unattend.txt > networking.
|
Windows Registry Editor Version 5.00 |
Back in NT4 we had sysdiff, that would create a registry snapshot and save it as an .inf file. This was very handy. However sysdiff won't work in windows XP or higher. As far as I know there is no other Microsoft tool to create inf files. There might be 3rd party apps.
Back to top
Below are some of my inf files that you can use for references or in your unattended install.
Install.inf - This is my main inf used for setup. It has all my custom registry tweaks, it deletes registry keys, registers my programs, and finally cleans up.
Services.inf - This disables services that aren't needed during setup. Called the section called Safe_to_disable_xp_pro
Mru.inf - This is not used during setup. I use this after setup to cleanup mru's - most recently used lists.
Options.inf - This adds custom settings to internet options and folder options. I run this so after the install, the end user can change settings not in the GUI.
Back to top