Submitted by Unknown
If you would prefer to use an INF file to control RunOnceEx, you can follow gosh's guide to learn how here.
Some of you may have trouble understanding how to create your own RunOnceEx.cmd file as outlined in this guide, as it has a steeper learning curve than batch files. eagle00789 over at the MSFN Forums has created an application to simplify this, known as the RunOnceEx.cmd Creator.
» Getting Started
First of all, remove the [GuiRunOnce] entries in winnt.sif, as RunOnceEx can be used to replace [GuiRunOnce] completely. Although you can use both if needed for some reason, but they will both run at the same time, so use caution.
To start RunOnceEx on first logon, we will need to import the registry keys during GUI-mode of Windows Setup. We can do this by using cmdlines.txt which executes a series of commands during the T-12 minute stage of Windows XP Setup. Create a cmdlines.txt file in Notepad and paste in the following:
Save this as cmdlines.txt inside the $OEM$ folder within your Windows Setup Source folder. If there currently isn't one created, create one. While we're on the subject, feel free to read about the $OEM$ Distribution Folders
» Creating your RunOnceEx.cmd file
This file will contain the syntax using REG.exe to import entries into the Windows Registry. This different method of importing registry entries allows the %systemdrive% environment variable to be used. The other method of using *.reg files requires a fixed drive letter (environment variables won't work), which isn't perfect if we wanted to install Windows onto D:\ or E:\ on a different PC.
Here is an example of what you can use:
cmdow @ /HID @echo off SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx REG ADD %KEY% /V TITLE /D "Installing Applications" /f REG ADD %KEY%\005 /VE /D "Adobe Reader 6" /f REG ADD %KEY%\005 /V 1 /D "%systemdrive%\install\AdobeReader6\AR6.msi /qn" /f REG ADD %KEY%\010 /VE /D "Alcohol 120" /f REG ADD %KEY%\010 /V 1 /D "%systemdrive%\install\alcohol\setup.exe /qn" /f REG ADD %KEY%\010 /V 2 /D "REGEDIT /S %systemdrive%\install\alcohol\register.reg" /f REG ADD %KEY%\015 /VE /D "Diskeeper 8" /f REG ADD %KEY%\015 /V 1 /D "%systemdrive%\install\DiskeeperPro_8.0.459.exe /s /v/qn" /f REG ADD %KEY%\050 /VE /D "Importing Registry Tweaks" /f REG ADD %KEY%\050 /V 1 /D "REGEDIT /S %systemdrive%\install\regtweaks.reg" /f REG ADD %KEY%\055 /VE /D "Cleaning Up and Rebooting" /f REG ADD %KEY%\055 /V 1 /D "%systemdrive%\install\cleanup.cmd" /f EXIT
Save this as RunOnceEx.cmd in C:\XPCD\$OEM$\
You may have noticed the 5 number gaps between each registry key. This allows you to easily maintain your list by adding another application between two existing keys, (for example, we have 001 and 005, we can add additional keys of 002, 003 or 004). Customize it as you wish. Each task is run in numerical order.
» Understanding the RunOnceEx.cmd file
This sets the registry address "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx" to a variable, called %KEY%. This saves on having to specify the full path every time we use REG ADD.
REG ADD %KEY% /V TITLE /D "Installing Applications" /f
This sets the title of the Window. The wording surrounded in quotations is customizable.
REG ADD %KEY%\010 /VE /D "Alcohol 120" /f
This sets the name of a task you want to process, and appears on the RunOnceEx window.
REG ADD %KEY%\010 /V 1 /D "%systemdrive%\install\alcohol\setup.exe /qn" /f REG ADD %KEY%\010 /V 2 /D "REGEDIT /S %systemdrive%\install\alcohol\register.reg" /f
You can assign several tasks to "Alcohol 120" by using /V 1, 2, 3 and so on.
As you can see in the RunOnceEx screenshot, the little arrow won't move to the next application until all those tasks have completed.
In short, all you really need to do is duplicate each REG ADD entry, but change the numbering and everything enclosed in quotations. If you want more information, type REG ADD /? at the Command Prompt.
What is cmdow @ /HID? This is a tool designed to hide your command line window from the end user. You can get cmdow.exe here. Place cmdow.exe into the \$OEM\$$\System32\ directory, so cmdow is copied over during Setup, and then the tool can be executed from anywhere without a direct path to the \Windows\System32 folder.
NOTE: CMDOW.EXE has been declared as a virus by Symantec Antivirus. Although it is not a virus, systems with SAV installed will automatically quarantine CMDOW.EXE upon use.
» Applications that use Quotations
You will find that if you add additional " " quotation marks in the REG ADD entries, it won't be imported to the Windows Registry. To work around this, use a backslash \" for every quotation you intend to add, for example:
%KEY%\005 /V 1 /D "\"%systemdrive%\install\AdobeReader6\Adobe Reader 6.msi\" /qn" /f
By doing this, you can execute applications that contain spaces in the filename, or application switches that need to be enclosed in quotations.
If there is an application that has a series of complicated switches with lots of quotation marks, consider putting them into a separate .cmd file instead and launching from RunOnceEx, because it would get too messy putting those switches directly into RunOnceEx.
This is optional. You can use cmd files to do tasks that would otherwise be messy if you added them to the REG ADD entries in RunOnceEx.cmd file. To see how this file is executed, please see the RunOnceEx.cmd example file near the top of this page.
Cleanup.cmd can contain the delete and reboot commands, such as:
cmdow @ /HID shutdown.exe -r -f -t 60 -c "Windows XP will now restart in 1 minute..." net user aspnet /delete DEL "%systemroot%\*.bmp" DEL "%systemroot%\Web\Wallpaper\*.jpg" DEL "%systemroot%\system32\dllcache\*.scr" DEL "%systemroot%\system32\*.scr" DEL "%AllUsersProfile%\Start Menu\Windows Update.lnk" DEL "%AllUsersProfile%\Start Menu\Set Program Access and Defaults.lnk" DEL "%AllUsersProfile%\Start Menu\Windows Catalog.lnk" RD /S /Q %systemdrive%\drivers\ RD /S /Q %systemdrive%\install\ EXIT
To summarize, RunOnceEx.cmd will be executed during the GUI-mode of Windows XP Setup at the T-12 Minute stage. This, however, does NOT mean that your programs will install. After reboot and first logon, RunOnceEx will start as shown here, and begin installing your programs.
You can test your RunOnceEx.cmd file by executing it. All it does is import the registry entries into HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\. So you should open up Registry Editor to check that everything is correct. Once you have verified that it's all correct, you should delete all the entries there, as you don't want it running on next boot-up on your production system!
If, however, you want to go through the whole process, or want to execute your RunOnceEx entries immediately after importing, execute this line:
Advantages of using RunOnceEx:
- Sleek and professional to the end-user
- Easier to maintain
However, if you want to use a more customizable RunOnceEx, please have a look at this page.
You can check out my copy of RunOnceEx.cmd in the Examples section.
Last updated 2008-03-29 21:42:14 by Unknown