C# .NET - Access denied when opening PrintQueue on Local Print Server

Asked By Joel Zinn on 14-Oct-10 10:25 AM

I have client app that I am working on that is supposed to be able to manage print queues, such as resuming print jobs or purging jobs that have hung up.  The problem I am running in to is that I need to open the queue with appropriate rights to do that management. 
The exact error message I am getting is:

{"An exception occurred while populating the properties for the PrintQueue object. Win32 error: Access is denied."}

I am using the line  below to create the queue.

pq = new PrintQueue(ps, printQueue, PrintSystemDesiredAccess.AdministratePrinter);

However, this line returns an access denied.  I am an admin on the local box, so I can't image why I am having this issue.

If I open the queue like this:

pq = new PrintQueue(ps, printQueue);

The open works find, but when I try to access the jobs in that queue, I get the access denied message.

Any idea what I am doing wrong here?  Any help would be greatly appreciated.

Anurag replied to Joel Zinn on 14-Oct-10 11:01 AM
Its strange that inspite of using admin account u r not getting access.
 Troubleshooting: try using some other account for testing it
 As u have admin rights on ur machine try giving access to all groups in ur printer eg: give "users" group full rights.