SynopsisSets programs or executables to run at user logon, for specific users or all users of a local or remote computer.
- Set-StartUpApplication [-Name] [-Executable] [-RunOnce] [-ComputerName] [-Credential] [-WhatIf] [-Confirm]
- Set-StartUpApplication [-Name] [-Executable] [-User] [-RunOnce] [-ComputerName] [-Credential] [-WhatIf] [-Confirm]
DescriptionThe Set-StartUpApplication cmdlet is used to specify programs that you wish to run at user logon to a local or remote computer. This can be for specific users or all users of the machine. The program can also be set to run one time only by specifying the RunOnce parameter. By default the Set-StartUpApplication cmdlet will set programs to run at every user logon for all users of the computer.
- Name A user defined name for the program. This name will be used when writing to the registry and when referencing the program in the Remove-FromStartup cmdlet.
- Executable The launch string of the program to be run at logon, including the full path, executable name and any switches required.
- User Run the program at logon for the specified user only. If this is not specified the program will launch for all users of the computer at logon.
- RunOnce Run the program one time only. If this parameter is not specified the program will run at every logon.
- ComputerName The computer against which to run the cmdlet. By default this parameter will be populated with the name of the local computer.
- Credential The credentials under which to run the cmdlet. By default this cmdlet will run as the current user. Using this parameter and the Get-PSCredential cmdlet you can specify an alternate set of credentials under which to execute this command.
InputsSet-StartUpApplication accepts the output of the Get-StartUpApplication cmdlet as an input object, or the output of Get-PSLaunchLine when it has been run with the AsObject parameter. The Name, Executable, User and ComputerName parameters of Set-StartUpApplication each accept pipeline input by property name.
OutputsSet-StartUpApplication makes changes directly to the Windows registry and does not output any Powershell objects.
NotesThe Set-StartUpApplication cmdlet requires that the RPC service is started on the computer it is trying to access and that DNS services are available to resolve target host names.
Example 1This command will set the application 'MyApp' to run at logon for every user of the local computer:
Set-StartUpApplication -Name MyApp -Executable 'C:\Program Files\MyApp\MyApp.exe'
Example 2This command will set the application 'MyApp' to run the next time a user logs on to the local computer. After the command has run once it will be removed.
Set-StartUpApplication -Name MyApp -Executable 'C:\Program Files\MyApp\MyApp.exe' -RunOnce
Example 3This command will set the application 'MyApp' to run at logon every time the user ASmith logs into the computer PC01.
Set-StartUpApplication -Name MyApp -Executable 'C:\Program Files\MyApp\MyApp.exe' -User ASmith -Computer PC01
Example 4Get-StartUpApplication can be used in conjunction with Set-StartUpApplication. In this example the path for the application 'MyApp' that runs on PC01 will be retrieved and set to run at startup on PC02.
Get-StartupApplication -Name MyApp -Computer PC01 | Set-StartUpApplication -Computer PC02
Example 5Get-PSLaunchLine can also be used in conjunction with Set-StartUpApplication. In this example the script '\\Serv01\Scripts\MyScript.ps1' will be run non-interactively and hidden every time a user logs in to PC01.
Get-PSLaunchLine -AsObjeect -Script \\Serv01\Scripts\MyScript.ps1 -ExitOnExeccution -RunHidden -NonInteractive | Set-StartUpApplication -Computer PC01