The <RunOnce> Element

The <RunOnce> Element

The RunOnce element of Unattended can be used for many management tasks. For example, it can be used to install additional device drivers or Windows updates and patches, or to run .EXE files.

To see a list of the environment variables that RunOnce supports, see Environment Variables Supported by RunOnce Commands.

The <RunOnce> element can contain the following elements. For more information, click an element name.

Element Description
RunOnceCommand Sets a RunOnce command.
DisplayName Specifies the name of the RunOnceCommand.
Description Specifies a description of the RunOnceCommand.

Sample <RunOnce> Element

  <RunOnce>
<!--This element specifies additional programs and commands to run during setup-->
   <RunOnceCommand FilePath="C:\sample1.vbs" Attributes="/a /f /e" Flags="1" ErrorControl="1" Reboot="True" Timeout="100" Cloning="On">
      <DisplayName Value="MSDE Setup" />
      <Description Value="This RunOnce Command installs MSDE" />
   </RunOnceCommand>
</RunOnce>

Back to top

The <RunOnceCommand> Element

Syntax:

  
    <RunOnceCommand FilePath="
    File_Path_String"
     Attributes="
    Attributes_String"
     Flags="
    0|1"
     ErrorControl="
    0|1"
     Reboot="
    True|False"
     Timeout="
    Timeout_Integer"
     Cloning="
    On|Off" 
    />
  

File_Path_String can be a full local drive path or a UNC path and filename of the executable file to run. Batch files must be called using cmd.exe /c (for example: FilePath="%11%\cmd.exe" Attributes="/c \\RemotePath\batchfile.cmd").

Attributes_String is used to pass command-line arguments to the application.

Flags="0" indicates that the program should create the process and wait the number of seconds specified by the Timeout attribute for it to exit before continuing. Flags="1" indicates that the program should create the process and continue.

ErrorControl="0" indicates that the program should continue if an error is encountered; ErrorControl="1" indicates that the program should halt on an error.

Reboot="True " tells the program to complete the operation, reboot, and then continue. Reboot="False " tells the program to continue without rebooting.

Timeout_Integer specifies the time, in seconds, that a program is allowed to execute before being terminated. 0 indicates an infinite number of seconds. This value is ignored if Flags is set to 1.

Cloning="On" specifies that RunOnce will be executed after system cloning. “Off” specifies that RunOnce will be executed before system cloning. System cloning creates a run-time image that you can deploy to mass systems and ensure that each device contains a unique computer security ID (SID) and computer name. For more information about using the System Cloning component included with WEPOS, see this Microsoft website.

Note that the <RunOnceCommand> element can be used multiple times within a <RunOnce> element.

Example:

  <RunOnceCommand FilePath =“C:\samplel.vbs” Attributes=“/a /f /e” Flags=“1” ErrorControl=“l’ Reboot=“True” Timeout=100” Cloning =“On”/>

You can find many more samples of uses for this element below.

Sample <RunOnceCommand> Element: Install a Windows Security Patch

This is an example of installing a Windows Security Patch.

In this example, the Security Update for Windows XP (KB885835) will be installed by a Runonce command. The name of the downloaded patch is WindowsXP-KB885835-x86-ENU.exe and the patch is located on a computer named WEPOSSetup.

  <RunOnceCommand FilePath = "\\WEPOSSetup\WindowsPatches\WindowsXP-KB885835-x86-ENU.exe" Attributes = "/quiet" Flags = "1" ErrorControl = "1" Reboot = "False" Timeout = “0” Cloning = "Off">
   <DisplayName Value = "Install Security Update for Windows XP (KB885835)" />
   <Description Value = "This RunOnce Command installs Security Update for Windows XP (KB885835)" />
</RunOnceCommand>

Sample <RunOnceCommand> Element: Install an Application

This is an example of installing an application.

In this example, Microsoft SQL Server 2000 Desktop Engine (MSDE 2000) will be installed. The name of the downloaded installation package is MSDE2000A.exe. It has been downloaded and unpackaged in the MSDE folder on a computer named WEPOSSetup. The unpackaged install package is called setup.exe.

  <RunOnceCommand FilePath = "\\WEPOSSetup\WEPOSApps\MSDE\setup.exe" Attributes = "/q" Flags = "1" ErrorControl = "1" Reboot = "False" Timeout = “0” Cloning = "Off">
   <DisplayName Value = "Install MSDE 2000" />
   <Description Value = "This RunOnce Command installs MSDE 2000" />
</RunOnceCommand>

Sample <RunOnceCommand> Element: Turn on DUA and Set Its Properties

This is an example of turning on the Device Update Agent (DUA) service and modifying the settings. All of these settings are in the registry and are set in DUA.reg file. For more information about DUA registry settings, go to: https://msdn.microsoft.com/library/default.asp?url=/library/en-us/xpehelp/html/xetbsduaagentregistrysettings.asp

  <RunOnceCommand FilePath = "regedit.exe" Attributes = "-s \\WEPOSSetup\WEPOSSettings\DUA.reg" Flags = "1" ErrorControl = "1" Reboot = "False" Timeout = “0” Cloning = "Off">
   <DisplayName Value = "Turns on the DUA Service and sets the appropriate properties." />
   <Description Value = "Turns on the DUA Service and sets the appropriate properties." />
</RunOnceCommand>

The DUA.reg file would have the following contents:

  Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\DUAgent]
"Start"=dword:00000002

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\DUAgent\Parameters]

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\DUAgent\Parameters\Config]
"RunOnStart"=dword:00000000
"PollInterval"=dword:00000000
"PollJitter"=dword:00000000
"PollToD"=hex:40,ff,ff,ff,20,ff,ff,ff,10,ff,ff,ff,08,ff,ff,ff,04,ff,ff,ff,02,\
 ff,ff,ff,01,ff,ff,ff

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\DUAgent\Parameters\Config\Sessions]

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\DUAgent\Parameters\Config\Sessions\0000]
"Type"=dword:00000000
"CmdFile"=hex(2):43,00,3a,00,5c,00,57,00,49,00,4e,00,44,00,4f,00,57,00,53,00,\
 5c,00,74,00,65,00,6d,00,70,00,00,00

Sample <RunOnceCommand> Element: Add an Environment Variable

This is an example of creating an environment variable.

  <RunOnceCommand FilePath = "cmd.exe" Attributes = "set sample=WEPOS" Flags = "1" ErrorControl = "1" Reboot = "False" Timeout = “0” Cloning = "Off">
   <DisplayName Value = "Sets sample to WEPOS." />
   <Description Value = "Creates an environment variable named sample and sets it to WEPOS." />
</RunOnceCommand>

Sample <RunOnceCommand> Element: Add a Hook for System Integrator’s Scripts

This is an example of having a placeholder for scripts where a system integrator could just add a script to finalize the OS configuration.

In this example, the OEM creates a RunOnce Command that the system integrator will use to run any needed applications or to specify configuration settings. The system integrator will need to create a batch file located in C:\Windows\AppSetup and called SystemIntegrator.bat.

  <RunOnceCommand FilePath = "cmd.exe" Attributes = "/c C:\AppSetup\SystemIntegrator.bat -s \\WEPOSSetup\WEPOSSettings\WindowsShell.reg" Flags = "1" ErrorControl = "1" Reboot = "False" Timeout = “0” Cloning = "On">
   <DisplayName Value = "Notepad Shell" />
   <Description Value = "Changes the Windows Shell to the Notepad Application." />
</RunOnceCommand>

Sample <RunOnceCommand> Element: Set an Application Other Than Explorer as the Shell

This is an example of changing the shell of Windows.

In this example, the shell is set to Notepad and Notepad opens the WEPOS Setup log. All of these settings are in the registry and are set in WindowsShell.reg file.

  <RunOnceCommand FilePath = "regedit.exe" Attributes = "-s \\WEPOSSetup\WEPOSSettings\WindowsShell.reg" Flags = "1" ErrorControl = "1" Reboot = "False" Timeout = “0” Cloning = "Off">
   <DisplayName Value = "Notepad Shell" />
   <Description Value = "Changes the Windows Shell to the Notepad Application." />
</RunOnceCommand>

The WindowsShell.reg file would have the following contents:

  Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"Shell"="notepad.exe C:\Windows\WINePOSSetup.log"

Sample <RunOnceCommand> Element: Disable Windows Media Player 9.0 Auto Update Functionality

This is an example of disabling Windows Media Player 9.0 auto update functionality.

  <RunOnceCommand FilePath = "regedit.exe" Attributes = "-s \\WEPOSSetup\WEPOSSettings\DisableWMPAutoUpdate.reg" Flags = "1" ErrorControl = "1" Reboot = "False" Timeout = “0” Cloning = "Off">
   <DisplayName Value = "Disable WMP 9.0 Auto Update Functionality" />
   <Description Value = "This command disables Windows Media Player 9.0 auto update functionality." />
</RunOnceCommand>

The WindowsShell.reg file would have the following contents:

  Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\ Software\Policies\Microsoft\WindowsMediaPlayer]
"DisableAutoUpdate"="1"

Back to top

The <DisplayName> Element

Syntax:

  
    <DisplayName Value="
    Name_String" /
    >
  

Name_String contains the name of the RunOnceCommand. The name can be up to 64 characters long, and can include any character supported by the language specified in <UserInterface>.

Example:

  <DisplayName Value="MSDE Setup" />

Back to top

The <Description> Element

Syntax:

  
    <Description Value="
    Description_String" /
    >
  

Description_String contains a description of the RunOnceCommand. The description can be up to 256 characters long, and can include any character supported by the language specified in <UserInterface>.

Example:

  <Description Value="This RunOnce Command installs MSDE" />

Back to top

© 2005 Microsoft Corporation. All rights reserved.