Click or drag to resize
Xcalibur Systems LLC Logo

ProcessHelperCreateProcessAsUser Method

Creates a new process and its primary thread. The new process runs in the security context of the user represented by the specified token.

CreateProcessAsUser function


Namespace: Xcalibur.NativeMethods.V2.Processes
Assembly: Xcalibur.NativeMethods.V2 (in Xcalibur.NativeMethods.V2.dll) Version: 1.0.1.0
Syntax
[DllImportAttribute("advapi32.dll", CallingConvention = CallingConvention.StdCall, 
	CharSet = CharSet.Ansi, SetLastError = true)]
public static bool CreateProcessAsUser(
	IntPtr tokenHandle,
	string applicationName,
	string commandLine,
	ref SecurityAttributes processAttributes,
	ref SecurityAttributes threadAttributes,
	bool inheritHandles,
	int creationFlags,
	IntPtr environmentHandle,
	string currentDirectory,
	ref StartupInfo startupInfo,
	out ProcessInformation processInformation
)

Parameters

tokenHandle  IntPtr
A handle to the primary token that represents a user. The handle must have the , , and access rights. For more information, see Access Rights for Access-Token Objects. The user represented by the token must have read and execute access to the application specified by the applicationName or the commandLine parameter.
applicationName  String
The name of the module to be executed. This module can be a Windows-based application. It can be some other type of module (for example, MS-DOS or OS/2) if the appropriate subsystem is available on the local computer.
commandLine  String
The command line to be executed. The maximum length of this string is 32K characters. If lpApplicationName is NULL, the module name portion of lpCommandLine is limited to MAX_PATH (260) characters.
processAttributes  SecurityAttributes
A pointer to a structure that specifies a security descriptor for the new process object and determines whether child processes can inherit the returned handle to the process. If processAttributes is NULL or SECURITY_ATTRIBUTES.lpSecurityDescriptor is NULL, the process gets a default security descriptor and the handle cannot be inherited. The default security descriptor is that of the user referenced in the tokenHandle parameter. This security descriptor may not allow access for the caller, in which case the process may not be opened again after it is run. The process handle is valid and will continue to have full access rights.
threadAttributes  SecurityAttributes
A pointer to a structure that specifies a security descriptor for the new thread object and determines whether child processes can inherit the returned handle to the thread. If SECURITY_ATTRIBUTES.lpSecurityDescripto is NULL or lpSecurityDescriptor is NULL, the thread gets a default security descriptor and the handle cannot be inherited. The default security descriptor is that of the user referenced in the hToken parameter. This security descriptor may not allow access for the caller.
inheritHandles  Boolean
If this parameter is TRUE, each inheritable handle in the calling process is inherited by the new process. If the parameter is FALSE, the handles are not inherited. Note that inherited handles have the same value and access rights as the original handles.
creationFlags  Int32
The flags that control the priority class and the creation of the process. For a list of values, see .
environmentHandle  IntPtr
A pointer to an environment block for the new process. If this parameter is NULL, the new process uses the environment of the calling process.
currentDirectory  String
The full path to the current directory for the process. The string can also specify a UNC path.
startupInfo  StartupInfo
A pointer to a or STARTUPINFOEX structure.
processInformation  ProcessInformation
A pointer to a structure that receives identification information about the new process.

Return Value

Boolean
If the function fails, the return value is zero. To get extended error information, call .
See Also