Discussion:
CreateProcessW in a service fails with error c0000142 ("DLL Initialization Failed") due to desktop restrictions ?
(too old to reply)
Xavier Roche
2012-01-26 08:52:16 UTC
Permalink
Hi folks,

I have a service running as a non-privileged user (a local system
.\user), and I am using CreateProcessW() to install some MSI executable
package in "unattended" mode (setup.exe /q), using the local
Administrator credentials.

When executing the executables, the return code (GetExitCodeProcess())
is -1073741502 (c0000142, "DLL Initialization Failed"). The failing DLL
name is unfortunately not given :)

However, KB 165194 (http://support.microsoft.com/kb/165194) suggests
that CreateProcessAsUser() might fail with a "Initialization of the
dynamic library <system>\system32\user32.dll failed" error because of
restricted access to the desktop.

Rather than attempting to access the interactive desktop session and
request necessary rights (as suggested in KB), is there a clean way to
create a "dummy" desktop session with proper rights ? Would this be
sufficient to solve the issue ? [Note: using the interactive session is
hopeless in this case, because there is no user interacting at all]

Thanks in advance for any hints :)
Stefan Kuhr
2012-01-26 10:24:51 UTC
Permalink
Hi Xavier,
Post by Xavier Roche
Hi folks,
I have a service running as a non-privileged user (a local system
.\user), and I am using CreateProcessW() to install some MSI executable
package in "unattended" mode (setup.exe /q), using the local
Administrator credentials.
When executing the executables, the return code (GetExitCodeProcess())
is -1073741502 (c0000142, "DLL Initialization Failed"). The failing DLL
name is unfortunately not given :)
This sounds strange. Can you doublecheck with a process of your own, for
example a console app that only links against kernel32.dll and returns
some specific exit code such as 42. It could well be that setup.exe
actually does an exit(0xc0000142) somewhere in its code.

You could also check if you are using default windowstation allocation
policy or specifying a certain winsta\desktop combination. How does the
lpDesktop member of the STARTUPINFO structure look like that you pass to
CreateProcessW? If it is "winsta0\\default" then try passing NULL, which
is default windowstation allocation policy (your service should normally
run in a different windowstation than winsta0).
Post by Xavier Roche
However, KB 165194 (http://support.microsoft.com/kb/165194) suggests
that CreateProcessAsUser() might fail with a "Initialization of the
dynamic library <system>\system32\user32.dll failed" error because of
restricted access to the desktop.
This is the typical scenario if you naively call CreateProcessAsUser
without adjusting the DACL of winsta0 and your desktop.
--
S
d***@gmail.com
2019-06-30 15:33:39 UTC
Permalink
That's actually mean insufficient permissions.

You have to add -h key.

Loading...