FirstLogonCommands specifies commands to run the first time a user logs on to the computer. These commands are run only once.
Commands run during
FirstLogonCommands are silently elevated (as long as the logged-on user has administrative privileges) because running these commands requires either editing the registry with administrative privileges or launching Windows Setup with
FirstLogonCommands specified in an unattended installation answer file. If the user does not have administrative privileges, a dialog box opens asking if the user needs to enable the program to run.
FirstLogonCommands run only when an account with administrator privilege logs onto the computer. If a non-administrator account logs onto the computer, commands that are listed in the
FirstLogonCommand settings are not executed.
FirstLogonCommands are run after logon but prior to showing the desktop.
FirstLogonCommands launches all commands synchronously and launches the next one only after the previous command has completed. The "synchronous" nature of these commands means that the next
FirstLogonCommands is not launched until the previous
FirstLogonCommands finishes, as determined by waiting on the process handle. If you set the first
FirstLogonCommands to launch something else asynchronously by creating a second process so the first process can terminate quickly, the next
RunOnce command will execute concurrently with the second process created by the first command. Other processes, such as services, are not gated by
FirstLogonCommands and will continue to start or to terminate independently of
FirstLogonCommands runs in the user context.
Specifies a command to run the first time a user logs on to the computer, its description, and the order in which it is run.
Microsoft-Windows-Shell-Setup | FirstLogonCommands
For the list of the supported Windows editions and architectures that this component supports, see Microsoft-Windows-Shell-Setup.
This setting is available to OEMs and system builders.
The following XML output shows how to set first logon commands.
<FirstLogonCommands> <SynchronousCommand wcm:action="add"> <CommandLine>c:synccommands\command1.exe</CommandLine> <Description>Description_of_command1</Description> <Order>1</Order> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <CommandLine>c:synccommands\command2.exe</CommandLine> <Description>Description_of_command2</Description> <Order>2</Order> </SynchronousCommand> </FirstLogonCommands>