Skip to main content
Version: 4.1.x

Start-ADTProcessAsUser

SYNOPSIS

Invokes a process in another user's session.

SYNTAX

Default_CreateWindow_Wait (Default)

Start-ADTProcessAsUser [-Username <NTAccount>] -FilePath <String> [-ArgumentList <String[]>]
[-SecureArgumentList] [-WorkingDirectory <String>] [-UseLinkedAdminToken] [-UseHighestAvailableToken]
[-InheritEnvironmentVariables] [-ExpandEnvironmentVariables] [-DenyUserTermination] [-WaitForMsiExec]
[-MsiExecWaitTime <TimeSpan>] [-WaitForChildProcesses] [-KillChildProcessesWithParent]
[-PriorityClass <ProcessPriorityClass>] [-PassThru] [<CommonParameters>]

Default_WindowStyle_Timeout

Start-ADTProcessAsUser [-Username <NTAccount>] -FilePath <String> [-ArgumentList <String[]>]
[-SecureArgumentList] [-WorkingDirectory <String>] [-UseLinkedAdminToken] [-UseHighestAvailableToken]
[-InheritEnvironmentVariables] [-ExpandEnvironmentVariables] [-DenyUserTermination]
-WindowStyle <ProcessWindowStyle> [-WaitForMsiExec] [-MsiExecWaitTime <TimeSpan>] [-WaitForChildProcesses]
[-KillChildProcessesWithParent] -Timeout <TimeSpan> [-TimeoutAction <ActionPreference>]
[-NoTerminateOnTimeout] [-SuccessExitCodes <Int32[]>] [-RebootExitCodes <Int32[]>]
[-IgnoreExitCodes <String[]>] [-PriorityClass <ProcessPriorityClass>] [-ExitOnProcessFailure] [-PassThru]
[<CommonParameters>]

Default_WindowStyle_NoWait

Start-ADTProcessAsUser [-Username <NTAccount>] -FilePath <String> [-ArgumentList <String[]>]
[-SecureArgumentList] [-WorkingDirectory <String>] [-UseLinkedAdminToken] [-UseHighestAvailableToken]
[-InheritEnvironmentVariables] [-ExpandEnvironmentVariables] [-DenyUserTermination]
-WindowStyle <ProcessWindowStyle> [-WaitForMsiExec] [-MsiExecWaitTime <TimeSpan>] [-WaitForChildProcesses]
[-KillChildProcessesWithParent] [-PriorityClass <ProcessPriorityClass>] [-NoWait] [-PassThru]
[<CommonParameters>]

Default_WindowStyle_Wait

Start-ADTProcessAsUser [-Username <NTAccount>] -FilePath <String> [-ArgumentList <String[]>]
[-SecureArgumentList] [-WorkingDirectory <String>] [-UseLinkedAdminToken] [-UseHighestAvailableToken]
[-InheritEnvironmentVariables] [-ExpandEnvironmentVariables] [-DenyUserTermination]
-WindowStyle <ProcessWindowStyle> [-WaitForMsiExec] [-MsiExecWaitTime <TimeSpan>] [-WaitForChildProcesses]
[-KillChildProcessesWithParent] [-SuccessExitCodes <Int32[]>] [-RebootExitCodes <Int32[]>]
[-IgnoreExitCodes <String[]>] [-PriorityClass <ProcessPriorityClass>] [-ExitOnProcessFailure] [-PassThru]
[<CommonParameters>]

Default_CreateNoWindow_Timeout

Start-ADTProcessAsUser [-Username <NTAccount>] -FilePath <String> [-ArgumentList <String[]>]
[-SecureArgumentList] [-WorkingDirectory <String>] [-UseLinkedAdminToken] [-UseHighestAvailableToken]
[-InheritEnvironmentVariables] [-ExpandEnvironmentVariables] [-DenyUserTermination] [-CreateNoWindow]
[-StreamEncoding <Encoding>] [-NoStreamLogging] [-WaitForMsiExec] [-MsiExecWaitTime <TimeSpan>]
[-WaitForChildProcesses] [-KillChildProcessesWithParent] -Timeout <TimeSpan>
[-TimeoutAction <ActionPreference>] [-NoTerminateOnTimeout] [-SuccessExitCodes <Int32[]>]
[-RebootExitCodes <Int32[]>] [-IgnoreExitCodes <String[]>] [-PriorityClass <ProcessPriorityClass>]
[-ExitOnProcessFailure] [-PassThru] [<CommonParameters>]

Default_CreateNoWindow_NoWait

Start-ADTProcessAsUser [-Username <NTAccount>] -FilePath <String> [-ArgumentList <String[]>]
[-SecureArgumentList] [-WorkingDirectory <String>] [-UseLinkedAdminToken] [-UseHighestAvailableToken]
[-InheritEnvironmentVariables] [-ExpandEnvironmentVariables] [-DenyUserTermination] [-CreateNoWindow]
[-StreamEncoding <Encoding>] [-NoStreamLogging] [-WaitForMsiExec] [-MsiExecWaitTime <TimeSpan>]
[-WaitForChildProcesses] [-KillChildProcessesWithParent] [-PriorityClass <ProcessPriorityClass>] [-NoWait]
[-PassThru] [<CommonParameters>]

Default_CreateNoWindow_Wait

Start-ADTProcessAsUser [-Username <NTAccount>] -FilePath <String> [-ArgumentList <String[]>]
[-SecureArgumentList] [-WorkingDirectory <String>] [-UseLinkedAdminToken] [-UseHighestAvailableToken]
[-InheritEnvironmentVariables] [-ExpandEnvironmentVariables] [-DenyUserTermination] [-CreateNoWindow]
[-StreamEncoding <Encoding>] [-NoStreamLogging] [-WaitForMsiExec] [-MsiExecWaitTime <TimeSpan>]
[-WaitForChildProcesses] [-KillChildProcessesWithParent] [-SuccessExitCodes <Int32[]>]
[-RebootExitCodes <Int32[]>] [-IgnoreExitCodes <String[]>] [-PriorityClass <ProcessPriorityClass>]
[-ExitOnProcessFailure] [-PassThru] [<CommonParameters>]

Default_CreateWindow_Timeout

Start-ADTProcessAsUser [-Username <NTAccount>] -FilePath <String> [-ArgumentList <String[]>]
[-SecureArgumentList] [-WorkingDirectory <String>] [-UseLinkedAdminToken] [-UseHighestAvailableToken]
[-InheritEnvironmentVariables] [-ExpandEnvironmentVariables] [-DenyUserTermination] [-WaitForMsiExec]
[-MsiExecWaitTime <TimeSpan>] [-WaitForChildProcesses] [-KillChildProcessesWithParent] -Timeout <TimeSpan>
[-TimeoutAction <ActionPreference>] [-NoTerminateOnTimeout] [-SuccessExitCodes <Int32[]>]
[-RebootExitCodes <Int32[]>] [-IgnoreExitCodes <String[]>] [-PriorityClass <ProcessPriorityClass>]
[-ExitOnProcessFailure] [-PassThru] [<CommonParameters>]

Default_CreateWindow_NoWait

Start-ADTProcessAsUser [-Username <NTAccount>] -FilePath <String> [-ArgumentList <String[]>]
[-SecureArgumentList] [-WorkingDirectory <String>] [-UseLinkedAdminToken] [-UseHighestAvailableToken]
[-InheritEnvironmentVariables] [-ExpandEnvironmentVariables] [-DenyUserTermination] [-WaitForMsiExec]
[-MsiExecWaitTime <TimeSpan>] [-WaitForChildProcesses] [-KillChildProcessesWithParent]
[-PriorityClass <ProcessPriorityClass>] [-NoWait] [-PassThru] [<CommonParameters>]

DESCRIPTION

Invokes a process from SYSTEM in another user's session.

EXAMPLES

EXAMPLE 1

Start-ADTProcessAsUser -FilePath 'setup.exe' -ArgumentList '/S' -IgnoreExitCodes 1,2

Launch InstallShield "setup.exe" from the ".\Files" sub-directory.

EXAMPLE 2

Start-ADTProcessAsUser -FilePath "$($adtSession.DirFiles)\Bin\setup.exe" -ArgumentList '/S' -WindowStyle 'Hidden'

Launch InstallShield "setup.exe" from the ".\Files\Bin" sub-directory.

EXAMPLE 3

Start-ADTProcessAsUser -FilePath 'uninstall_flash_player_64bit.exe' -ArgumentList '/uninstall' -WindowStyle 'Hidden'

If the file is in the "Files" directory of the AppDeployToolkit, only the file name needs to be specified.

EXAMPLE 4

Start-ADTProcessAsUser -FilePath 'setup.exe' -ArgumentList "-s -f2`"$((Get-ADTConfig).Toolkit.LogPath)\$($adtSession.InstallName).log`""

Launch InstallShield "setup.exe" from the ".\Files" sub-directory and force log files to the logging folder.

EXAMPLE 5

Start-ADTProcessAsUser -FilePath 'setup.exe' -ArgumentList "/s /v`"ALLUSERS=1 /qn /L* `"$((Get-ADTConfig).Toolkit.LogPath)\$($adtSession.InstallName).log`"`""

Launch InstallShield "setup.exe" with embedded MSI and force log files to the logging folder.

PARAMETERS

-Username

A username to invoke the process as. Only supported while running as the SYSTEM account.

Type: NTAccount
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: $RunAsActiveUser.UserName
Accept pipeline input: False
Accept wildcard characters: False

-FilePath

Path to the file to be executed. If the file is located directly in the "Files" directory of the App Deploy Toolkit, only the file name needs to be specified.

Otherwise, the full path of the file must be specified. If the files is in a subdirectory of "Files", use the "$($adtSession.DirFiles)" variable as shown in the example.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: [System.Management.Automation.Language.NullString]::Value
Accept pipeline input: False
Accept wildcard characters: False

-ArgumentList

Arguments to be passed to the executable.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SecureArgumentList

Hides all parameters passed to the executable from the Toolkit log file.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WorkingDirectory

The working directory used for executing the process. Defaults to the directory of the file being executed. The use of UseShellExecute affects this parameter.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: [System.Management.Automation.Language.NullString]::Value
Accept pipeline input: False
Accept wildcard characters: False

-UseLinkedAdminToken

Use a user's linked administrative token while running the process under their context.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-UseHighestAvailableToken

Use a user's linked administrative token if it's available while running the process under their context.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-InheritEnvironmentVariables

Specifies whether the process running as a user should inherit the SYSTEM account's environment variables.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ExpandEnvironmentVariables

Specifies whether to expand any Windows/DOS-style environment variables in the specified FilePath/ArgumentList.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-DenyUserTermination

Specifies that users cannot terminate the process started in their context. The user will still be able to terminate the process if they're an administrator, though.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WindowStyle

Style of the window of the process executed. Options: Normal, Hidden, Maximized, Minimized. Only works for native Windows GUI applications. If the WindowStyle is set to Hidden, UseShellExecute should be set to $true.

Note: Not all processes honor WindowStyle. WindowStyle is a recommendation passed to the process. They can choose to ignore it.

Type: ProcessWindowStyle
Parameter Sets: Default_WindowStyle_Timeout, Default_WindowStyle_NoWait, Default_WindowStyle_Wait
Aliases:
Accepted values: Normal, Hidden, Minimized, Maximized

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-CreateNoWindow

Specifies whether the process should be started with a new window to contain it.

Type: SwitchParameter
Parameter Sets: Default_CreateNoWindow_Timeout, Default_CreateNoWindow_NoWait, Default_CreateNoWindow_Wait
Aliases:

Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-StreamEncoding

Specifies the encoding type to use when reading stdout/stderr. Some apps like WinGet encode using UTF8, which will corrupt if incorrectly set.

Type: Encoding
Parameter Sets: Default_CreateNoWindow_Timeout, Default_CreateNoWindow_NoWait, Default_CreateNoWindow_Wait
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-NoStreamLogging

Don't log any available stdout/stderr data to the log file.

Type: SwitchParameter
Parameter Sets: Default_CreateNoWindow_Timeout, Default_CreateNoWindow_NoWait, Default_CreateNoWindow_Wait
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WaitForMsiExec

Sometimes an EXE bootstrapper will launch an MSI install. In such cases, this variable will ensure that this function waits for the msiexec engine to become available before starting the install.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-MsiExecWaitTime

Specify the length of time in seconds to wait for the msiexec engine to become available.

Type: TimeSpan
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WaitForChildProcesses

Specifies whether the started process should be considered finished only when any child processes it spawns have finished also.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-KillChildProcessesWithParent

Specifies whether any child processes started by the provided executable should be closed when the provided executable closes. This is handy for application installs that open web browsers and other programs that cannot be suppressed.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Timeout

How long to wait for the process before timing out.

Type: TimeSpan
Parameter Sets: Default_WindowStyle_Timeout, Default_CreateNoWindow_Timeout, Default_CreateWindow_Timeout
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-TimeoutAction

What action to take on timeout. Follows ErrorAction if not specified.

Type: ActionPreference
Parameter Sets: Default_WindowStyle_Timeout, Default_CreateNoWindow_Timeout, Default_CreateWindow_Timeout
Aliases:
Accepted values: SilentlyContinue, Stop, Continue, Inquire, Ignore, Suspend

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-NoTerminateOnTimeout

Indicates that the process should not be terminated on timeout. Only supported for GUI-based applications, or when -CreateNoWindow isn't specified.

Type: SwitchParameter
Parameter Sets: Default_WindowStyle_Timeout, Default_CreateNoWindow_Timeout, Default_CreateWindow_Timeout
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-SuccessExitCodes

List of exit codes to be considered successful. Defaults to values set during ADTSession initialization, otherwise: 0

Type: Int32[]
Parameter Sets: Default_WindowStyle_Timeout, Default_WindowStyle_Wait, Default_CreateNoWindow_Timeout, Default_CreateNoWindow_Wait, Default_CreateWindow_Timeout
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-RebootExitCodes

List of exit codes to indicate a reboot is required. Defaults to values set during ADTSession initialization, otherwise: 1641, 3010

Type: Int32[]
Parameter Sets: Default_WindowStyle_Timeout, Default_WindowStyle_Wait, Default_CreateNoWindow_Timeout, Default_CreateNoWindow_Wait, Default_CreateWindow_Timeout
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-IgnoreExitCodes

List the exit codes to ignore or * to ignore all exit codes.

Type: String[]
Parameter Sets: Default_WindowStyle_Timeout, Default_WindowStyle_Wait, Default_CreateNoWindow_Timeout, Default_CreateNoWindow_Wait, Default_CreateWindow_Timeout
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-PriorityClass

Specifies priority class for the process. Options: Idle, Normal, High, AboveNormal, BelowNormal, RealTime.

Type: ProcessPriorityClass
Parameter Sets: (All)
Aliases:
Accepted values: Normal, Idle, High, RealTime, BelowNormal, AboveNormal

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ExitOnProcessFailure

Automatically closes the active deployment session via Close-ADTSession in the event the process exits with a non-success or non-ignored exit code.

Type: SwitchParameter
Parameter Sets: Default_WindowStyle_Timeout, Default_WindowStyle_Wait, Default_CreateNoWindow_Timeout, Default_CreateNoWindow_Wait, Default_CreateWindow_Timeout
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-NoWait

Immediately continue after executing the process.

Type: SwitchParameter
Parameter Sets: Default_WindowStyle_NoWait, Default_CreateNoWindow_NoWait, Default_CreateWindow_NoWait
Aliases:

Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-PassThru

If -NoWait is not specified, returns an object with ExitCode, StdOut, and StdErr output from the process. If -NoWait is specified, returns a task that can be awaited. Note that a failed execution will only return an object if either -ErrorAction is set to SilentlyContinue/Ignore, or if -IgnoreExitCodes/-SuccessExitCodes are used.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

None

You cannot pipe objects to this function.

OUTPUTS

PSADT.Types.ProcessResult

Returns an object with the results of the installation if -PassThru is specified.

- ProcessId

- ExitCode

- StdOut

- StdErr

- Interleaved

NOTES

An active ADT session is NOT required to use this function.

Tags: psadt
Website: https://psappdeploytoolkit.com
Copyright: (C) 2025 PSAppDeployToolkit Team (Sean Lillis, Dan Cunningham, Muhammad Mashwani, Mitch Richters, Dan Gough).
License: https://opensource.org/license/lgpl-3-0

https://psappdeploytoolkit.com/docs/reference/functions/Start-ADTProcess

Look for us at these events...

MMS: Music City Edition 2025
October 12th to 15th • Nashville, Tennessee, USA
Up Next
AppManage2025AppManage2025
October 10th • Utrecht, The Netherlands
MAEDS Fall Conference 2025MAEDS Fall Conference 2025
October 29th to 31st • Michigan, USA