joe_pool_is Posted October 5, 2009 Posted October 5, 2009 I recently had to open a project because someone on our production floor did not know how to navigate the menus. When I tried to run it, I got an Unauthorized Access Exception for code that I had not modified. This query worked before installing VS2008, but now it will not run in a test application under VS2005 either. My code fails in the foreach loop when the printer is assigned at this line: (ManagementObject printer in Printers) public static void GetPrintersCollection() { try { string sql = "SELECT * FROM Win32_Printer"; using (ManagementObjectSearcher query = new ManagementObjectSearcher(sql)) { ManagementObjectCollection Printers = query.Get(); foreach (ManagementObject printer in Printers) { Console.WriteLine(printer.Properties["Name"].Value.ToString()); } } } catch (UnauthorizedAccessException err) { // err.Message is empty Console.WriteLine("You do not have authorization to access this printer."); } catch (Exception err) { Console.WriteLine(err.Message); } } Any ideas why? Help! Please, and Thank You! Quote Avoid Sears Home Improvement
joe_pool_is Posted October 6, 2009 Author Posted October 6, 2009 I have traced the problem down as far as Event Viewer, where the error shows up under the local System tab, and I do not know how to resolve this. Here is a screen shot of the error: http://sites.google.com/site/jp2code/home/list/wmiprvse-Event.gif The description of the error is as follows (if the image is ever deleted): Source: DCOM EventID: 10000 User: NT AUTHORITY\NETWORK SERVICE Description: Unable to start a DCOM Server: {1F87137D-0E7C-44D5-8C73-4EFFB68962F2}. The error: "Access is denied. " Happened while starting this command: C:\WINDOWS\system32\wbem\wmiprvse.exe -secured -Embedding For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. The link, however, is broken on my machine. Any help in troubleshooting this problem is greatly appreciated. Regards, ~Joe Quote Avoid Sears Home Improvement
Administrators PlausiblyDamp Posted October 8, 2009 Administrators Posted October 8, 2009 (edited) Has anything else changed apart from installing 2008? One possibility is a change in permissions for your network account. If you have a good backup of ytour system you could try resetting the machine permissions to the default by typing secedit /configure /cfg %windir%\repair\secsetup.inf /db secsetup.sdb /verbose at a command prompt. Have you tried the executable on any other machine to see if it generates the same error? Edited October 8, 2009 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.