Microsoft KB Archive/158447

= INFO: How to Run a Program Only Once After Unattended Setup of Windows NT =

Article ID: 158447

Article Last Modified on 11/1/2006

-

APPLIES TO


 * Microsoft Windows NT Workstation 4.0 Developer Edition
 * Microsoft Windows NT Server 4.0 Standard Edition

-



This article was previously published under Q158447





SUMMARY
The unattended setup mode of Windows NT 4.0 does not offer a way to run a program once the setup is complete. Nevertheless, this functionality may be very useful if you want to set up other components on your system after the completion of the unattended setup (for example, running a batch file, launching a hands-free service pack update, or starting the setup routine of other products).

This article describes how to run a program once (after an unattended setup has completed).



MORE INFORMATION
Automatically running any kind of program after an unattended setup has completed is not normally possible. The following steps explain how to run a program only once after an unattended setup has completed.

Windows NT must be installed with the AutoLogon option enabled so that the system automatically logs itself onto the network immediately after setup is complete, thus allowing a session to be automatically opened and a specific program to be launched.

For additional information about enabling AutoLogon for initial logon after running Windows NT 4.0 Setup, please see the following article in the Microsoft Knowledge Base:

157361 How to Automatically Log On After an Unattended Setup

To set up Windows NT 4.0 and to run a program automatically after the setup has completed, use one of the following methods:

Method 1
 Create a new share on a network server and then copy the i386 folder (or appropriate platform folder) from the Windows NT 4.0 compact disc to the new share. Obtain the Regini.exe program from the Windows NT 4.0 Resource Kit and place it in the shared network installation point.  Using a text editor (such as Notepad), create a text file and name it Runonce.ini. Save the file to the shared network installation point. In this file, create the following entries (making sure to place a carriage return at the end of each line):

  \Registry\Machine Software Microsoft Windows CurrentVersion Run RUNBATCH = REG_SZ "BATCH.CMD"   Add the following entry to the [Unattended] section of the Unattend.txt file:

OEMPreinstall = Yes   Add the following entries to the [GUIUnattended] section of the Unattend.txt file:

DetachedProgram = "%SystemRoot%\System32\REGINI.EXE" Arguments = "%SystemRoot%\System32\RUNONCE.INI"

For additional information about parameters for the Unattend.txt file, please see the following article in the Microsoft Knowledge Base:

155197 Unattended Setup Parameters for Unattend.txt File

 Save and close the Unattend.txt file.</li>  Using a text editor, create a text file and save it to the shared network installation point as Cleanup.inf. The contents of the Cleanup.inf file must be:

[Version] signature="$CHICAGO$"

[DefaultInstall] DelReg = Delete.Reg

[Delete.Reg] HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Run","RUNBATCH" </li>  Using a text editor, create a batch file and save it to the shared network installation point as Batch.cmd. This batch file can include any command, and will be run only once after the unattended setup has completed. The Batch.cmd file must also contain the following lines:

%SystemRoot%\System32\rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 %SystemRoot%\System32\cleanup.inf

NOTE: The above command should be all on one line; the line is wrapped for readability.

Triggering the Cleanup.inf file in this manner prevents the running of the Batch.cmd file in future logons. </li>  During the first phase of the unattended setup, all system files are temporarily copied to C:\$Win_nt$.~ls and C:\$Win_nt$.~bt. The Dosnet.inf lists the files that have to be copied to the system.

Therefore, the next step is to edit the Dosnet.inf and add the following lines to the end of the [Files] section:

d1,REGINI.EXE d1,RUNONCE.INI d1,BATCH.CMD d1,CLEANUP.INF </li>  The Txtsetup.sif file is used during the text-mode phase of the unattended setup. This file tells the setup process which files have to be copied to the hard disk.

The next step is to modify the Txtsetup.sif file in the shared network installation point. Add the following lines to the end of the [SourceDisksFiles] section of the Txtsetup.sif file:

BATCH.CMD  = 1,,,,,,,2,0,0 REGINI.EXE = 1,,,,,,,2,0,0 RUNONCE.INI = 1,,,,,,,2,0,0 CLEANUP.INF = 1,,,,,,,2,0,0

Adding these lines causes the files above to be copied to the System32 directory. </li> Run Setup using the appropriate switches, specifying the Unattend.txt file containing the modifications discussed above.</li></ol>

Method 2
<ol> Create a $oem$ directory under the I386 directory.</li>  Create a registry file by exporting the Runonce.ini file out of the registry. The file should look similar to the following:

REGEDIT4 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce] @="c:\\WinNT\\System32\\Calc.exe"

NOTE: Replace "C:\\WinNT\\Sytem32\\Calc.exe" with whatever command you want to run. Give the file a descriptive name, such as Runonce.reg. </li> Copy Regedit.exe to the $oem$ directory.</li>  Use a text editor to create a file named Cmdlines.txt. In this file, add the following lines:

[commands] ".\regedit /s runonce.reg" </li> In the Unattend.txt file, make sure you have OEMPREINSTALL set to "Yes".</li> Run unattended setup for Windows NT 4.0.</li></ol>

Additional query words: 4.00 prodnt deployment sysdiff unattended Setup Install

Keywords: kbfaq kbinfo kbsbk kbsetup KB158447

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.