Adding Settings to Unattend.txt


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):

  • REG files.

    For more information about creating REG files, see Chapter 2, “Using Registry Editor,” and Chapter 11, “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 11, “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 Script Host, see Chapter 11, “Scripting Registry Changes.” You run a script using the command wscript filename.ext, where ext is either vbs or js.

  • OPS files.

    For more information about creating and installing OPS files, see Chapter 17, “Deploying Office 2003 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.exe).

    For more information about using Reg.exe to edit the registry, see Chapter 2, “Using Registry Editor,” and Chapter 11, “Scripting Registry Changes.” Reg.exe 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 13, “Mapping Windows Installer.” To learn how to build MSI files that install registry settings, see Chapter 11, “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]” 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]:

  • You can't run programs from [GuiRunOnce]that force Windows to restart. That's because when Windows restarts, it loses any entries remaining in [GuiRunOnce], and those commands 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]. You won't experience this issue with any of the commands that add registry settings.

  • When you use [GuiRunOnce], 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 want to install Windows Installer package files from [GuiRunOnce], you must use the /wait command-line option in order to ensure that two packages don't try to install at the same time. Otherwise, both packages fail. This is an issue only when using Setup.exe to install Windows Installer packages, however, because Setup.exe launches Windows Installer and then returns, allowing the next package to begin installing immediately. If you instead use Msiexec (the Windows Installer command-line interface) to install Windows Installer packages, you won't experience this issue.

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]:

  • Environment variables are not available.

  • When using Cmdlines.txt, 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, and no network connection is guaranteed. The result is that Windows stores settings in the default user hive file so that all users receive the same settings.

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



Microsoft Windows Registry Guide
Microsoft Windows Registry Guide, Second Edition
ISBN: 0735622183
EAN: 2147483647
Year: 2003
Pages: 186

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