RE: CreateProcessAsUser fails with ERROR_PIPE_NOT_CONNECTED

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello Yuri Martsinovsky,

Good morning Yuri Martsinovsky, welcome to
microsoft.public.win32.programmer.kernel NewsGroup. I am Rongchun
Zhang[MSFT], it is my pleasure to work with you on this issue.

First please let me describe the problem briefly. You are calling
CreateProcessAsUser() from a windows service on the WTS_SESSION_LOGON event
in order that a certain process can be started into the user's session when
he logs on. CreateProcessAsUser sometimes fails with
ERROR_PIPE_NOT_CONNECTED.

I performed the research of the case and find the a relevant issue in our
database. In that issue, it says that the problem only happens to pre-Vista
machines e.g. Windows XP (Is this the case on your side?).

=====
CAUSE

The error happens when Logon complete notification is not yet sent by
winlogon. The root cause is that, in certain environments depending on
system performance it is possible that WTS_SESSION_LOGON notification is
sent for a non-zero session before it is available for process creation.
CreateProcessAsUser() fails if you are feeding it 'winsta0\\default'
because the desktop you are targeting is not yet created.

PROCESS_INFORMATION processInfo = {0};
STARTUPINFO startupInfo;
ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
startupInfo.lpDesktop = _T("winsta0\\default");
ccLib::CString sParams; <-- contains the full command line
CreateProcessAsUser(hNewProcessToken, NULL, sParams.GetBuffer(), NULL,
NULL, FALSE, CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS |
CREATE_UNICODE_ENVIRONMENT, m_pEnvironment, NULL, &startupInfo,
&processInfo);

This thread has a relevant discussion of the cause of
ERROR_PIPE_NOT_CONNECTED.
http://www.eggheadcafe.com/software/aspnet/30553990/createprocessasuser-from
aspx.

The problem is not heard to happen in Windows Vista because session 0.

=====
SOLUTION

The only solution is to wait and try again. (There is no notification sent
when desktop becomes ready.) This problem does not occur in Windows Vista
and later, therefore the product group does not plan to fix it in Windows
XP. I understand that it is not the ideal solution but this is only
workaround available.


Best regards,
Rongchun Zhang (v-rzhang@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • RE: GDI+ error with Remote Desktop
    ... The application runs well if not running through Remote Desktop. ... you have a WinForm application on a Windows ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: System time change notification
    ... have a windows UI, it is not an actual issue for me. ... But since server application will run in Session 0 in Vista, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.win32.programmer.tools)
  • Re: interrupting a lengthy sequence
    ... Winform GUI normally runs in a single thread, so when the GUI thread is ... Windows messages currently in the message queue. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Problem with Process.GetCurrentProcess() when starting a servi
    ... System is Windows XP. ... to send the sample project to me by removing "online." ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.general)
  • RE: The debugger component on the server failed to connect to the
    ... my computer is running under Windows XP ... In Component Services, expand Component Services, expand Computers, and ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vsnet.debugging)