函数参考


_WinAPI_CreateProcessWithToken

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

#Include <WinAPIEx.au3>
_WinAPI_CreateProcessWithToken ( $sApp, $sCmd, $iFlags, $pStartupInfo, $pProcessInfo, $hToken [, $iLogon [, $pEnvironment [, $sDir]]] )

参数

$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杁elimited 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 [可选参数] The logon option. This parameter can be zero or one of the following values.

$LOGON_WITH_PROFILE
$LOGON_NETCREDENTIALS_ONLY
$pEnvironment [可选参数] A pointer to an environment block for the new process.
$sDir [可选参数] The path to the current directory for the process. If this parameter is an empty string, the new
process will have the same current drive and directory as the calling process.

返回值

成功: 返回 1.
失败: 返回 0 并设置 @error 标志为非 0 值.

注意/说明

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

本函数需要 Windows Vista 或更高版本系统.

相关

详情参考

在MSDN中搜索