Function Reference


_WinAPI_CreateProcessWithToken

Creates a new process and its primary thread in the security context of the specified token

#include <WinAPIProc.au3>
_WinAPI_CreateProcessWithToken ( $sApp, $sCmd, $iFlags, $tStartupInfo, $tProcessInfo, $hToken [, $iLogon = 0 [, $pEnvironment = 0 [, $sDir = '']]] )

Parameters

$sApp The name of the module to be executed. If this parameter is an empty string, the module name must be the first white space–delimited token in the command line string.
$sCmd The command line to be executed. If this parameter is an empty string, the function uses the module name as the command line.
$iFlags The flags that control how the process is created.
The $CREATE_DEFAULT_ERROR_MODE, $CREATE_NEW_CONSOLE, and $CREATE_NEW_PROCESS_GROUP are enabled by default.
You can specify additional flags as noted:
    $CREATE_DEFAULT_ERROR_MODE
    $CREATE_NEW_CONSOLE
    $CREATE_NEW_PROCESS_GROUP
    $CREATE_SEPARATE_WOW_VDM
    $CREATE_SUSPENDED
    $CREATE_UNICODE_ENVIRONMENT
$tStartupInfo a $tagSTARTUPINFO structure or a pointer to it.
$tProcessInfo a $tagPROCESS_INFORMATION structure or a pointer to it that receives information for the new process, including a handle to the process.
$hToken A handle to the primary token that represents a user. The handle must have the $TOKEN_QUERY, $TOKEN_DUPLICATE, and $TOKEN_ASSIGN_PRIMARY access rights.
$iLogon [optional] The logon option. This parameter can be zero or one of the following values:
    $LOGON_WITH_PROFILE
    $LOGON_NETCREDENTIALS_ONLY
$pEnvironment [optional] A pointer to an environment block for the new process.
$sDir [optional] The path to the current directory for the process.
If this parameter is an empty string (Default), the new process will have the same current drive and directory as the calling process.
Constants are defined in APIProcConstants.au3

Return Value

Success: True
Failure: False

Remarks

To retrieve a security token, pass the process handle in the $tagPROCESS_INFORMATION structure to the _WinAPI_OpenProcessToken() function.

This function requires Windows Vista or later.

Related

_WinAPI_OpenProcessToken

See Also

Search CreateProcessWithTokenW in MSDN Library.