###User Defined Function###
_WinAPI_CreateProcessWithToken

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

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


###Parameters###
@@ParamTable@@
$sApp
	The name of the module to be executed. If this parameter is an empty string, the module name must be the first white spacedelimited 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
$pStartupInfo
	A pointer to a $tagSTARTUPINFO structure.
$pProcessInfo
	A pointer to a $tagPROCESS_INFORMATION structure 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.
@@End@@

###ReturnValue###
@@ReturnTable@@
Success 	True
Failure 	False
@@End@@


###Remarks###
To retrieve a security token, pass the process handle in the $tagPROCESS_INFORMATION structure to the <a href="_WinAPI_OpenProcessToken.htm">_WinAPI_OpenProcessToken()</a> function.

This function requires <strong>Windows Vista or later</strong>.


###Related###
_WinAPI_OpenProcessToken


###See Also###
@@MsdnLink@@ CreateProcessWithTokenW
