Microsoft Windows Registry Guide, Second Edition

Adding Settings to Unattend.txt

Now you know how to build answer files and how to use them. It's time to get to the main point, which is how to deploy user settings with your answer file. To deploy settings with Windows, you need a mechanism for running a program during the setup process. The Windows setup program provides two different mechanisms, but first, think of all the different ways to add settings to the registry (and this is only a partial list):

Now that I've reminded you of the many tools and commands that I describe in this book for installing registry settings, see the following two sections, “[GuiRunOnce]” and “Cmdlines.txt,” to learn how to deploy those commands with Windows.

[GuiRunOnce]

The [GuiRunOnce] section contains a list of commands that run the first time that a user logs on to the computer after the Windows setup program runs. Enclose each command in quotation marks. The commands in the [GuiRunOnce] section run in the context of the console user, so you must ensure that the user has the privileges necessary to run each command. You can use this feature to install a REG file when a user logs on to the computer. For example, add the following lines to your answer file to import Settings.reg into the registry the first time that a user logs on to the computer:

[GuiRunOnce] "regedit %SYSTEMROOT%\Settings.reg /s"

You must provide any programs and data files that you want to use, though, and you do that by deploying them through the $OEM$ distribution folders that you learned about in “Creating Distribution Folders,” earlier in this chapter. In the previous example of a [GuiRunOnce] section, I put Settings.reg in i386\$OEM$\$$ to make sure that the setup program copied it to %SystemRoot% on the target computer. Also, make sure that a program that you run from [GuiRunOnce] has a command-line option to run quietly; you don't want to display a user interface while installing registry settings. All the commands that I listed in the section “Adding Settings to Unattend.txt” include the command-line option for running without displaying a user interface.

Another method for deploying settings is running Profile Wizard from the Microsoft Office 2003 Editions Resource Kit. Add the following lines to your answer file. You must also make sure that the Windows setup program copies Proflwiz.exe and Settings.ops to the target computer. In this case, I put both files in i386\$OEM$\$$:

[GuiRunOnce] "%SYSTEMROOT%\Proflwiz.exe /r %SYSTEMROOT%\Settings.ops /q"

Here are three things to consider when using [GuiRunOnce]:

TIP

The commands in the [GuiRunOnce] section run asynchronously, which means that they can potentially all run at the same time. If you'd rather run commands synchronously–one at a time–create a batch file that runs the program using the Start command's /wait command-line option. The syntax is Start /wait program, where program is the path and the name of the program file. The /wait command-line option prevents the Start program from returning control to the batch file until program finishes. Then run this batch file from [GuiRunOnce].

Cmdlines.txt

The file Cmdlines.txt contains commands that the GUI-mode portion of the setup program runs when installing optional components, including applications that the setup program must install immediately after installing Windows. The commands in Cmdlines.txt run as a system service, so they run with elevated privileges. You put Cmdlines.txt in the $OEM$ subfolder of the Windows distribution folder. You put into Cmdlines.txt the same kinds of commands that you'd put into [GuiRunOnce]. You also must use the $OEM$ folder to copy data files, such as REG files, INF files, and scripts, to the target computer.

The format of Cmdlines.txt is simple. It has a single section called [Commands], followed by zero or more commands. If the command contains spaces, then it's a good idea to enclose each command in quotation marks. The following sample imports a REG file called Settings.reg and installs an INF file called Config.inf. (It assumes that I added both files to $OEM$\$$ in the distribution folder.)

[Commands] "regedit.exe %SYSTEMROOT%\Settings.reg /s" "rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 \Windows\Config.inf"

In some important aspects, though, using Cmdlines.txt is different from using [GuiRunOnce]:

Категории