This cmdlet is part of the Vexasoft Cmdlet Library. You can download it now or click here to find out more.

Set-StartUpApplication

Synopsis

Sets programs or executables to run at user logon, for specific users or all users of a local or remote computer.

Syntax

  • Set-StartUpApplication [-Name] [-Executable] [-RunOnce] [-ComputerName] [-Credential] [-WhatIf] [-Confirm]
  • Set-StartUpApplication [-Name] [-Executable] [-User] [-RunOnce] [-ComputerName] [-Credential] [-WhatIf] [-Confirm]

Description

The 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.

Parameters

  • 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.

Inputs

Set-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.

Outputs

Set-StartUpApplication makes changes directly to the Windows registry and does not output any Powershell objects.

Notes

The 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 1

This 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 2

This 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 3

This 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 4

Get-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 5

Get-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