Unattended Install Tricks

Does making Registry changes and adding service packs after every unattended NT installation irritate you? Here's how to incorporate those changes into your NT setup?

Mark Minasi

August 31, 1998

6 Min Read
ITPro Today logo in a gray background | ITPro Today

Incorporate preferences into your standard unattended installation

In last month's Inside Out, I started digging into the details of unattendedWindows NT installations. I looked beyond basic scripts to figure out how toperform unattended installs on machines that have new or unusual hardware. This month, I'll show you how to save yourself a few steps on NT installations.

I prefer to do all my browsing in one window rather than let My Computeropen numerous windows. I don't want the Recycle Bin to prompt me every time I recycle a file. I like to see hidden files and file extensions. I want to turn off Autorun for CD-ROMs, get rid of the Welcome Screen tips, and make sure files' entire paths appear in the title bar. I want to load Service Pack 3 (SP3) on all my machines. Having to specify these preferences in every new NT installation irritates me. But, setting these preferences doesn't need to be a lot of work.

Cmdlines.txt
You can use cmdlines.txt, one of the less-documented features of NT Setup, to incorporate NT commands into an unattended installation. Cmdlines.txt is a special type of batch file; it is an ASCII file with the syntax

[Commands]
""
""

The first line must be [Commands]. Each of the file's following linescontains a command you want NT Setup to execute. Double quotes must surroundeach command.

To tell NT Setup to look for cmdlines.txt, you must use an installationscript with the OemPreinstall option enabled. (For information about writingunattended setup scripts, see Christa Anderson, "Designing Unattended NT Installations," March 1997.) The shortest possible installation script you can build to use cmdlines.txt is

[Unattended]
OemPreinstall = yes
Save these two lines as an ASCII file named simple.inf.

Because you enable OemPreinstall, your i386 directory must contain an$OEM$ directory. NT Setup looks for the directory when it performs OEMpreinstalls. Place cmdlines.txt in the i386$OEM$ directory.

To quickly zap NT onto new machines, I keep i386 on a share called\sharemachi386. This practice lets me boot DOS and the MS-DOS Network Client on a new machine, attach to \sharemachi386, and install NT from across the network. I don't even need to map to \sharemachi386 to install NT on a new system; I type

winnt /s:\sharemachi386 /u:simple.inf

at a command prompt to start an NT installation.

Registry Fixes
To add Registry changes to your unattended installation, you need acommand-line tool that can modify the Registry. Many systems administrators like regini (which comes in Microsoft Windows NT Server 4.0 Resource Kit), but regedit's command-line options are plenty powerful for the setup I'm describing.

To disable Autorun on my CD-ROM drive, I must modify the Autorun valueentry in the HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesCdromRegistry key. Autorun is a REG_DWORD entry. If you set it to 0, CD-ROMs won't run automatically when you insert them. I create a four-line ASCII file, cdfix.reg, that looks like

REGEDIT4

[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesCdrom]
"Autorun"=dword:00000000

Notice how the regedit syntax works: The first line is REGEDIT4. Next, you need a blank line. Then, you specify which key you want to work with, inbrackets. Finally, you include the value entry. You can make a bunch of Registry changes with one regedit file. For example, Listing 1, page 58, contains Registry changes for all the preferences I mentioned previously.

To tell regedit to apply cdfix.reg's Registry change, I open a command line and type

regedit /s cdfix.reg

The /s tells regedit not to prompt me when it makes the change. When Ireboot my machine, Autorun will be off.

A Dynamic Duo
Now, you're ready to use regedit files and cmdlines.txt together. Collectall your regedit Registry changes in an ASCII file (let's call it fixnt.reg). Copy fixnt.reg and regedit.exe to your $OEM$ directory. Create a cmdlines.txt file with the following contents

[Commands]
".regedit /s .fixnt.reg"

Note the . characters; I've included them to be certain that NT Setup can find both regedit and fixnt.reg. The . characters point to the currentdirectory. By default, NT Setup copies all the files in $OEM$ on thedistribution share point to the C:$WIN_NT$.~LS$OEM$ directory on the target PC's hard disk, but hardwiring the directory name into cmdlines.txt causes a problem if you ever need to tell NT Setup to place temporary files in a directory other than C:. The . reference works better because it's relative. Place cmdlines.txt in your $OEM$ directory.

You can also use cmdlines.txt to automatically install SP3 during NTinstallations. To include SP3 in unattended installations, I keep SP3 on theshare \sharmachsp3. According to Microsoft's Knowledge Base article Q168814, "Installing WinNT 4.0 Service Packs During Unattended Install" http://support.microsoft.com/support/kb/articles/q168/8/14.asp), you can use the command update -u -z to run an unattended installation of SP3. I write the following batch file, which I call spinst.cmd:

net use y: \sharmachsp3 /persistent:no /user:mydomaininstguyswordfish
ren %systemroot%system32schannel.dll sc1.dll
y:
update -u -z
del %systemroot%system32schannel.dll
ren %systemrootsystem32sc1.dll schannel.dll
net use y: /delete

The first line of the batch file attaches to the network share that contains the SP3 files. The /user: parameter obtains authorization to access the share. Instguy is the username for a user in the mydomain domain. Instguy's password is swordfish. I hate to include a password in a batch file, but I can't figure out how to install SP3 without a password. For security reasons, I give instguy no permissions except read access to the SP3 share.

The second line of the batch file renames schannel.dll. Without this line, the SP3 installation won't continue until I confirm that I don't want it to overwrite my 128-bit security with SP3's 40-bit security. Although the -u parameter specifies that I want to use the unattended option, I haven't found a way to tell NT Setup, "When I say unattended, I mean unattended!" By renaming the 128-bit schannel.dll, I let the batch file install SP3's schannel.dll without any prompts because the .dll doesn't overwrite the 128-bit .dll. The batch file's fifth and sixth lines delete the 40-bit schannel.dll and restore the original file.

To incorporate the SP3 installation into my unattended NT installs, I add spinst.cmd to cmdlines.txt. My final cmdlines.txt file looks like

[Commands]
".regedit /s .fixnt.reg"
".spinst.cmd"

All my NT installations will now make the Registry changes I specify infixnt.reg and install SP3 automatically.

To tell NT Setup to add your preferences to every new NT installation, you need to complete these steps: Create an i386 share (or local directory) with an $OEM$ directory in it. Create an unattended installation script that contains the OemPreinstall = yes command. Place your favorite Registry fixes in an ASCII file and move the ASCII file and regedit.exe into the $OEM$ directory. Install an easily accessible copy of SP3. Create a short batch file to kick off SP3 installation in unattended mode. Create a cmdlines.txt file and save it in $OEM$. Then, use winnt or winnt32 to start the installation. You'll love the results!

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like