Using txtsetup.sif to add registry settings
One little known way to include custom registry entries is by using txtsetup.sif. The registry is created by txtsetup.sif at the very end of text mode setup (file copy phase). On a clean install, setup looks at txtsetup.sif's [HiveInfs.Fresh] section to build the registry. You can use this section to add your own registry entries to the registry.
Adding registry entries
If you already have your registry settings saved in a .reg file, you'll need to have the .inf import these settings. Rename your .reg file to settings.reg and put it into the i386 folder. Copy what's below to a new file called settings.inf and also save it into the i386 folder.
| [Version] Signature = "$Windows NT$" DriverVer=07/01/2001,5.1.2600.1106 [update] HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnce","MyUpdate",0x00020002,"%systemroot%\regedit.exe /s %systemroot%\system32\settings.reg" |
Adding inf entries
If you aleady have an .inf file, copy it to the i386 folder and rename it to settings.inf. Make sure the .inf has a section called [update] in it, only settings under this catagory will be used! You can compress settings.inf using makecat settings.inf, but this is optional.
Putting it together
Open txtsetup.sif and under [HiveInfs.Fresh] add what's below in bold.
| [HiveInfs.Fresh] AddReg = hivedef.inf,AddReg AddReg = hivesys.inf,AddReg AddReg = hivesft.inf,AddReg AddReg = hivecls.inf,AddReg AddReg = hiveusd.inf,AddReg AddReg = dmreg.inf,DM.AddReg AddReg = settings.inf,update |
Also add these 2 lines under the [SourceDisksFiles] section of txtsetup.sif. You only need to include the 2nd line if you're using a .reg file.
| settings.inf =1,,,,,,_x,3,,3 settings.reg =100,,,,,,,2,0,0 |
Add these lines under [Files] section of dosnet.inf. You only need to include the 2nd line if you're using a .reg file.
| d1,settings.inf d1,settings.reg |
Now when you install XP, text mode setup will use your registry keys. You don't need to do an unattend install for the settings to work.
Troubleshooting
Text mode setup uses a different redendering engine than SetupAPI. For this reason it's very picky and "dumb" about inf files. There's a couple guidelines to keep in mind when writing an inf for text mode.
1 - Avoid strings. A string represents something definded under
[strings]. I've heard that you cannot use a string in a key for text mode.
2 - Always use quotes. Put quotes around everything if you can.
3 - Never abbreviate. In a regular inf you could use 0x1 or 0x1002.
For text mode these values won't work.
4 - Avoid unnecessary spaces. This probably isn't mandatory, but i
think it's a good practice.
5 - Unsure if you can do something in a text mode .inf? Consult
hivesys.inf, hivesft.inf.
Below are 5 different .inf settings. The one in bold is correct, the others won't work and text mode will give an error.
1 - HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB826939","Installed",0x00010001,1
2 - HKLM,SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB826939,"Installed",0x00010001,1
3 - HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB826939","Installed",0x10001,1
4 - HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB826939","Installed"",0x00010001,1
5 - HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB826939",Installed,0x00010001,1
1 - This line won't have any errors. Notice that the 2nd and 3rd column is in quotes. You have to add these in quotes!
That's pretty much it. Make your inf and try to follow my guidelines. If text mode doesn't like your inf it will tell you what line has the error. Just go to that line in your inf and try to figure out what's wrong.
Credit
Portions of this guide, including the first inf file, where taken from material written by MSTest