Createprocessasuser Error 2
Contents |
from GoogleSign inHidden fieldsSearch for groups or messages
SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: Why am I getting Win32 https://groups.google.com/d/topic/microsoft.public.win32.programmer.kernel/H2nx_57Dp2A error 2: File Not Found? Windows Desktop Development > Windows Desktop SDK Question 0 Sign in to vote Hello everyone. I think I have an interesting issue at hand. It is not trivial, I think. I have a BHO that needs to spawn an executable in Low Integrity mode. For this, I borrowed a function https://social.msdn.microsoft.com/Forums/en-US/3ad304ed-5647-4262-9eea-2bbdb8c51938/why-am-i-getting-win32-error-2-file-not-found?forum=windowssdk from MSDN Online that duplicates the current token and adds the Low Integrity SID to the duplicate, and then uses CreateProcessAsUser() with this duplicated token. The function works OK and the process starts (it has a user interface that I see on screen), BUT the function also queries for the last Win32 error right after CreateProcessAsUser() and it turns out it throws 2 (FILE NOT FOUND). Why am I getting error #2 instead of 0 (ERROR_SUCCESS)? This is the function I am using: DWORD CreateLowProcess(LPCTSTR szProcessFileName) { BOOL bRet; HANDLE hToken; HANDLE hNewToken; // Low integrity SID TCHAR szIntegritySid[20] = TEXT("S-1-16-4096"); PSID pIntegritySid = NULL; TOKEN_MANDATORY_LABEL TIL = {0}; PROCESS_INFORMATION ProcInfo = {0}; STARTUPINFO StartupInfo = {0}; DWORD errCode = ERROR_SUCCESS; TCHAR szPFN[32768]; ::ZeroMemory(szPFN, sizeof(szPFN)); _tcscpy_s(szPFN, sizeof(szPFN) / sizeof(TCHAR), szProcessFileName); if (OpenProcessToken(GetCurrentProcess(),MAXIMUM_ALLOWED, &hToken)) { if (DuplicateTokenEx(hToken, MAXIMUM_ALLOWED, NULL, SecurityImpersonation, TokenPrimary, &hNewToken)) { if (ConvertStringSidToSid(szIntegritySid, &pIntegritySid)) { TIL.Label.Attributes = SE_GROUP_INTEGRITY; TIL.Label.Sid = pIntegritySid; // Set the process integrity level if (SetTokenInformation(hNewToken, TokenIntegrityLevel, &TIL, sizeof(TOKEN_MANDATOR
Campos MagencioMarch 9, 20122 0 0 0 Hi all, The other day I worked on a support case where a Windows service running as System in Session 0 was creating a processalso running as System in Session 0, and this new process https://blogs.msdn.microsoft.com/alejacma/2012/03/09/createprocessasuser-fails-with-error-5-access-denied-when-using-jobs/ failed to create another process in the logged-on user's session (Session 2 in this particular case). And it failed because CreateProcessAsUser API didn't work and returned error 5 (Access Denied). Note the issue happened on Windows 7, and http://eskonr.com/2013/05/createprocess-or-createprocessasuser-failed-to-execute-command-line-with-non-recoverable-error-2-execmgr-log/ because of Session 0 Isolation the logged-on user and the service (and its child process running as System) were running in different sessions. To understand what was going on exactly, I did some kernel debugging of error 2 the issue and saw that the error in CreateProcessAsUser happened when trying to bind the process we were trying to spawn to its parent's Job (the Job that the process that the service spawned as System was a member of). Indeed, I could verify with Process Explorerthat the process running as System in Session 0 was member of a Job, by checking the properties of the process and going to the Job tab (note: when there createprocessasuser error 2 is no Job, there is no Job tab). After a process is associated with a job, by default any child processes it creates are also associated with the job (see Job Objects for more details on this). But the following is also documented: AssignProcessToJobObject function"Terminal Services: All processes within a job must run within the same session as the job." Which means that, as the new process we are trying to create is in a different session than its parent, we will fail to bind it to its parent's Job. The only way to work around this, would be to create the process in the different session by passing this flag to the CreateProcessAsUser API: Process Creation Flags“CREATE_BREAKAWAY_FROM_JOB 0x01000000The child processes of a process associated with a job are not associated with the job. If the calling process is not associated with a job, this constant has no effect. If the calling process is associated with a job, the job must set the JOB_OBJECT_LIMIT_BREAKAWAY_OK limit. “ I hope this helps. Regards, Alex (Alejandro Campos Magencio) Tags NT Services Windows 7 Windows SDK Comments (2) Cancel reply Name * Email * Website Álvar García says: March 9, 2012 at 2:55 am Great info! Thanks. Reply Usman Janjua says: May 7, 2014 at 6:59 pm Very useful info this. Helped me resolve a cor
2007 SCCM 2012 Labs SQL Server 2005 MDOP About Author Thursday, 6 October 2016 You are here: Home 2013 May CreateProcess or CreateProcessAsUser failed to execute command line with non-recoverable error 2 execmgr.log CreateProcess or CreateProcessAsUser failed to execute command line with non-recoverable error 2 execmgr.log Posted on May 31, 2013 by Eswar Koneti | 0 Comments Recently i worked on issue with SCCM Client.Many applications are Advertised in Run Advertised programs as Optional(Optional can be set either not having mandatory schedule or allow users to run independently while creating Advertisement ). But none of the applications are running successfully from RAP .So verified CAS.log ,Datatransfer.log to see if any issues with content downloading to cache but they do work it. Next to look execmgr.log : From this log,what i noticed is ,Client is able to download the content and start the program command line but it failed with error message: CreateProcess or CreateProcessAsUser failed to execute command line with non-recoverable error 2 if you try ctrl+L from your trace32.exe and look for Error 2, it tells you,system can not find the file specified. There is nothing wrong with program command line as it works well on all other clients. Why does all the applications failed on this particular computer ?? Because Script DLL files are corrupted ,it requires to reregister them again. Below are the DLL files to register. regsvr32.exe jscript.dll regsvr32.exe vbscript.dll regsvr32.exe wshom.ocx regsvr32.exe msxml3.dll regsvr32.exe -i shell32.dll regsvr32.exe OLEAUT32.DLL Restart the computer ,try to run the applications from RAP window. It works this time 🙂 Share this:Click to share on Facebook (Opens in new window)Click to share on Twitter (Opens in new window)Click to share on Google+ (Opens in new window)Click to share on LinkedIn (Opens in new window)Click to print (Opens in new window)Click to email this to a friend (Opens in new window)Click to share on Reddit (Opens in new window)Like this:Like Loading... Filed in: SCCM 2007, Software Distribution, Troubleshooting Tips Tags: Applications failed to run from RAP, CreateProcess or CreateProcessAsUser failed, execmgr.log, non-recoverable error 2, Run Advertised prorgams Related Posts SCCM Configmgr How to Create collections based on OU that contains DEV UAT PROD etc SCCM Configmgr Report for Count of MS Office Versions updated with list of clients SCCM Configmgr 2012 R2 SP1 download content from M