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 heart of the matter, which is how to deploy user settings with your answer file. To deploy settings with Windows XP, you need a mechanism for running a program during the setup process. Windows XP's 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):

  • REG files. For more information about creating REG files, see Chapter 2, "Using the Registry Editor," and Chapter 9, "Scripting Registry Changes." You import a REG file using the command regedit filename.reg /s.

  • INF files. For more information about building and installing INF files, see Chapter 9, "Scripting Registry Changes." You install an INF file by running the command rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 filename.inf.

  • Scripts. For more information about writing scripts for Windows Scripting Host, see Chapter 9, "Scripting Registry Changes." You run a script using the command wscriptfilename.ext, where ext is either vbs or js.

  • OPS files. For more information about creating and installing OPS files, see Chapter 14, "Deploying Office XP Settings." You import an OPS file into the user's profile using the command proflwiz /r filename.ops /q.

  • Console Registry Tool for Windows (Reg). For more information about using Reg to edit the registry, see Chapter 2, "Using the Registry Editor," and Chapter 9, "Scripting Registry Changes." Reg has a robust command-line interface that enables you to edit the registry using batch files.

  • Windows Installer package files (MSI files). For more information about package files, see Chapter 11, "Mapping Windows Installer." To learn how to build MSI files that install registry settings, see Chapter 9, "Scripting Registry Changes."

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]

The [GuiRunOnce] section contains a list of commands that run the first time a user logs on to the computer after the Windows XP 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 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'd put Settings.reg in i386\$OEM$\$$ to make sure that the setup program copied it to %SYSTEMROOT% on the target computer. Also, you want to make sure that a program 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 I listed in the section "Adding Settings to Unattend.txt" include the command-line option to run without displaying a user interface.

Another method of deploying settings is running Profile Wizard from the Office XP Resource Kit. Add the following lines to your answer file. You must also make sure that the Windows XP 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 you should consider when using [GuiRunOnce]:

  • From [GuiRunOnce] you can't run programs that force Windows XP to restart. That's because Windows XP loses any entries remaining in [GuiRunOnce] when it restarts, and those command will not run. If you can't prevent the program from restarting the computer, try repackaging it as a Windows Installer package file or add it as the last command in [GuiRunOnce]. This isn't an issue for any of the commands I've given you that add registry settings.

  • Any program that relies on Windows Explorer will not work properly because Windows Explorer is not running when the commands in the [GuiRunOnce] section are. Again, you can consider repackaging these applications.

  • If you're trying to install Windows Installer package files from [GuiRunOnce], you must use the /wait command-line option to ensure that two packages don't try to install at the same time. Otherwise, both packages fail. This is an issue only when installing Windows Installer packages using Setup.exe, however, because Setup.exe launches Windows Installer and then returns, allowing the next package to begin installing immediately. If you install Windows Installer packages using Msiexec (the Windows Installer command-line interface) instead, this problem isn't an issue.

    Tip 

    The commands in the [GuiRunOnce] section run asynchronously, which means that they could 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 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 the setup program must install immediately after installing Windows XP. 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 XP distribution folder. You put the same kinds of commands in Cmdlines.txt that you'd put in [GuiRunOnce]. You also have to 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. Enclosing each command in quotation marks is a good idea if the command contains spaces. Here's a sample that imports a REG file called Settings.reg and installs an INF file called Config.inf, assuming that I added both files to $OEM$\$$ in the distribution folder:

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

Using Cmdlines.txt is different than [GuiRunOnce] in some important aspects, though:

  • You must create the $OEM$ distribution folders, and you must set OEMPreinstall=Yes in your answer file.

  • When the setup program runs the command in Cmdlines.txt, no user is logged on to Windows XP, and for that matter, no network connection is guaranteed. As a result, Windows XP stores settings in the default user hive file so all users receive the same settings.

  • You can't install Windows Installer packages using Cmdlines.txt.



Microsoft Windows XP Registry Guide
Microsoft Windows XP Registry Guide (Bpg-Other)
ISBN: 0735617880
EAN: 2147483647
Year: 2005
Pages: 185

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net