System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
This article was previously published under Q165194
When a process is started by means of the CreateProcessAsUser function, the process will be started into a windowstation and desktop combination based on the value of lpDesktop in the STARTUPINFO structure parameter:
If a windowstation and desktop combination is specified in the lpDesktop member, the system will try to start the process into that windowstation and desktop.
If the lpDesktop member is initialized to NULL, the system will try to use the same windowstation and desktop as the calling process if the system is associated with the interactive windowstation.
If the lpDesktop member is not initialized to NULL, the system will create a new windowstation and desktop that you cannot see.
If the system is initialized with the empty string, "", it will either create a new windowstation and desktop that you cannot see, or if one has been created by means of a prior call by using the same access token, the existing windowstation and desktop will be used.
Sometimes the process may fail to start, and one of the following
error messages may appear:
Error message 1
Initialization of the dynamic library <system>\system32\user32.dll failed. The process is terminating abnormally.
Error message 2
Initialization of the dynamic library
<system>\system32\kernel32.dll
failed. The process is terminating abnormally.
The error message occurs when the process that is started causes the
initialization code in either the User32.dll or the Kernel32.dll file to fail because of an API call from the started process that does not have correct security access to either the targeted windowstation or desktop. For example, if the process that was started was trying to create a window, the process would have to have DESKTOP_CREATEWINDOW access to the desktop object. If the process has not been granted this access right, an error would occur in the User32.dll file, which would cause the system error box to appear and the process would fail to start.
Note Sometimes the process may start, but fail to draw its GUI correctly.
The best method to resolve these and other potential access related problems is to grant the user full access to both the targeted windowstation and desktop. For example, if you want the process that is started by the CreateProcessAsUser function to be interactive, specify the following windowstation and desktop combination:
A new API was introduced beginning with Windows 2000, CreateProcessWithLogonW(). If the lpDesktop member of the STARTUPINFO structure is initialized to either NULL or "", CreateProcessWithLogonW() implementation adds permissions for the specified user account to the inherited window station and desktop. If the application specifies a desktop in the lpDesktop member, it is the responsibility of the application to add permission for the specified user account to the specified window station and desktop.
The following sample code grants the user named franki access to the
interactive windowstation and desktop, "winsta0\\default". Access is
granted based on the logon security ID (SID) of the user franki.
For more information about windowstations and desktops, see the
Win32 SDK documentation.
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
327618
(http://support.microsoft.com/kb/327618/
)
Security, services and the interactive desktop
The following sample code gives the user named "franki" full access to the
interactive windowstation and desktop, "winsta0\\default". The access
control entry (ACE) for each object is based on franki's logon SID. The
code executes the Cmd.exe file.
Note An application that runs many processes
such as a scheduler service may want to remove the new ACE after the
process has completed because the ACEs accumulate on the DACL of both
the windowstation and desktop object.
For more information, click the following article number to view the article in the Microsoft Knowledge Base: