Createdesktop Failed With Error 5 Access Is Denied
Contents |
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
Error 0x2105 Replication Access Was Denied
a processalso running as System in Session 0, and this new process failed dsreplicagetinfo(kcc_ds_connect_failures) failed with error 8453 to create another process in the logged-on user's session (Session 2 in this particular case). And it failed because the replication generated an error (5) access is denied CreateProcessAsUser API didn't work and returned error 5 (Access Denied). Note the issue happened on Windows 7, and because of Session 0 Isolation the logged-on user and the service (and its child
Time Skew Error Between Client And 1 Dcs
process running as System) were running in different sessions. To understand what was going on exactly, I did some kernel debugging of 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).
Dsbindwithspnex() Failed With Error 5
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 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
aprivate (hidden) desktop, and sends some keystrokes to it.So far I have gotten this to work with the replication access was denied server 2012 following code:HWINSTA hWinsta=OpenWindowStation(_T("WinSta0"), FALSE, MAXIMUM_ALLOWED);SetProcessWindowStation (hWinsta);HDESK hDesk=OpenDesktop(_T("Default"), 0, FALSE, MAXIMUM_ALLOWED);SetThreadDesktop
Domain Controller Access Denied
(hDesk);si.cb=sizeof(si);si.lpDesktop=_T("WinSta0\\Default");retval=CreateProcess(NULL, _T("D:\\Windows\\Notepad.exe"), NULL, NULL,FALSE, 0, NULL, NULL, &si, &pi);Sleep (2000);// ...// Use SendInput() to send ldap bind failed with error 8341 keystrokes that write some text, then doFile/Save As, c:\a.txt and enter.// ...Sleep (2000);TerminateProcess (pi.hProcess, 0);The above version works fine from the service. Notepad starts on https://blogs.msdn.microsoft.com/alejacma/2012/03/09/createprocessasuser-fails-with-error-5-access-denied-when-using-jobs/ my activedesktop, SendInput() sends the keystrokes to it successfully, and Notepadsaves the new file to c:\a.txt.Next I tried creating my own window station and desktop:HWINSTA hWinsta=CreateWindowStation(_T("NsWinSta"), 0, GENERIC_ALL, NULL);// ...HDESK hDesk=CreateDesktop(_T("NsDesktop"), NULL, NULL, 0, GENERIC_ALL,NULL);// ...si.lpDesktop=_T("NsWinSta\\NsDesktop");// ...All other code is the same as in the first example. When I run http://microsoft.public.platformsdk.ui.narkive.com/Xv1HViaV/sendinput-and-desktops-window-stations this codefrom the service, I can see a new Notepad process being created in TaskManager. The Notepad window does not appear on my desktop, as expected.However, the SendInput() calls fail with error code 5 (access denied).Is it possible to use SendInput() to send input to other desktops than theactive one? Do I need to enable some additional rights beyond GENERIC_ALLfor this to work?--Mikko Noromaa (***@excelsql.com)- SQL in Excel, check out ExcelSQL! - see http://www.excelsql.com - 2003-10-09 01:06:07 UTC PermalinkRaw Message No. Keyboard input only goes to the interactive desktop. Any thread that isnot on the interactive desktop that calls SendInput will fail. Mikko Noromaa 2003-10-09 02:05:41 UTC PermalinkRaw Message Hi,Post by No. Keyboard input only goes to the interactive desktop. Any thread that isnot on the interactive desktop that calls SendInput will fail.OK, good to know. Thanks!Are there any other ways of sending keystrokes to applications on other
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or http://stackoverflow.com/questions/413643/how-to-get-the-actual-path-of-a-file-in-vista-with-uac posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only https://www.experts-exchange.com/questions/20924938/Can't-rename-or-delete-newly-created-folder-in-Windows-Explorer.html takes a minute: Sign up How to get the actual path of a file in Vista with UAC? up vote 1 down vote favorite I am calling CreateFile() to create a file in the Program Data directory. I'm using SHGetSpecialFolderPath() failed with to get the dir name. I have a user with Vista for whom CreateFile() is returning error 5 (Access Denied). It would help if I knew where CreateFile() was actually attempting to create the file so we can check his folder permissions. The problem with Vista (UAC) is, it's not attempting to create the file in the directory I passed in. It could also be in a VirtualStore directory. An added source of confusion is this user is German and although failed with error SHGetSpecialFolderPath() is returning "C:\Program Data\blah blah" as the path, I don't think that's actually where the path is. I think German Vista uses the German word for "Program Data". I would like to be able to tell the user "This is the exact path where we are trying to create the file. Check your permissions on this folder." I know you can get the a path from an open file handle, but in this case the CreateFile() is failing so I don't have an open handle. How can I get Vista to tell me the actual path where it's attempting to create the file? windows-vista path uac createfile share|improve this question edited Jan 5 '09 at 18:08 asked Jan 5 '09 at 16:18 mhenry1384 4,64743549 What happens if the user is on Windows XP and is a standard user? Back then CSIDL_COMMON_APPDATA pointed to C:\Documents & Settings\All Users, and your CreateFile would also fail. (in other words the failure is not specific to Vista, but to your application. You shoudn't be writing to places your not supposed to be writing too) –Ian Boyd May 24 '11 at 18:23 fyi: SHGetSpecialFolderPath has been deprecated since Windows 2000; use SHGetFolderPath instead. Newer applications can use SHGetKnownFolderPath. –Ian Boyd May 24 '11 at 18:26 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote accepted Fire up Process Monitor and watch what it does: http://technet.microsoft.com/en
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > Can't rename or delete newly created folder in Windows Explorer!!! Want to Advertise Here? Solved Can't rename or delete newly created folder in Windows Explorer!!! Posted on 2004-03-19 Windows 2000 1 Verified Solution 18 Comments 1,448 Views Last Modified: 2010-04-14 I have Windows 2000 Professional SP4 I create a folder with default name, I then try to rename this folder and can't. I try to delete the folder and can't do it either. Deleting files works OK but folders for some reason can't be renamed, moved, or deleted. Obviously the problem here has something to do with deleting files since the two other commands rely on the delete command in order to function. Here is the funny thing: deleting or renaming the folder from the command line works ok. Another hint... probably has something to do with the recycler (recycle bin) been broken. Although, I have tried to re-create the recycle bin by removing it and deleting a file which goes and re-creates the folder. Any suggestions? seen this problem before? have a fix? 0 Question by:juanhf Facebook Twitter LinkedIn Google LVL 14 Best Solution byspiderfix Boot with the win2k CD "R" (repair) at the prompt type chkdsk /r Go to Solution 18 Comments LVL 15 Overall: Level 15 Windows 2000 5 Message Expert Comment by:mattisflones2004-03-19 Hi juanhf, Is this on a computer witch is in a domain or with settinngs in GPO attached, if so this can be caused by renaming of the account.. The fix on that is to reapply the securitysettings of all folders because the SID is broken.. Mattis 0 Message Author Comment by:juanhf2004-03-19 Mattis, Actually, the computer is stand-alone and the file system is FAT32. All local user accounts (problem occurs and