CreateProcessAsUser fails with ERROR_PIPE_NOT_CONNECTED

February 16th, 2009 - 01:56 pm ET by Yuri Martsynovskyy | Report spam
Hi,

I have a problem with CreateProcessAsUser funiction failing. I'm trying to
start a process into a user session at the moment when he logs on. I'm
calling CreateProcessAsUser () from the service on the WTS_SESSION_LOGON
event.
Sometimes CreateProcessAsUser fails with lasterror =
ERROR_PIPE_NOT_CONNECTED
Looks like some service that CreateProcessAsUser uses inside have not yet
started and I have to wait for it to start

Yuri Martsinovsky
email Follow the discussionReplies 3 repliesReplies Make a reply

Similar topics

Replies

#1 v-rzhang
February 17th, 2009 - 12:36 am ET | Report spam
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?).

ÊUSE

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...suser-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 (, 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:


=Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/sub...fications.

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...;ln=en-us.
=This posting is provided "AS IS" with no warranties, and confers no rights.
Replies Reply to this message
#2 Yuri Martsynovskyy
February 17th, 2009 - 02:53 pm ET | Report spam
Hi Rongchun,

Thanks for such a comlete answer. Indeed it happens on XP.
I was able to fix it using your suggested solution.

Yuri Martsinovsky
Replies Reply to this message
#3 v-rzhang
February 17th, 2009 - 09:53 pm ET | Report spam
Hi Yuri Martsinovsky,

I am glad that this workaround works for you. It's my pleasure to work with
you.

Have a great day!

Regards,
Rongchun Zhang (, 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:


This posting is provided "AS IS" with no warranties, and confers no rights.
email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search