PrintServer object. Access is denied. On Server 2016
j g
6
Reputation points
The following code works on my local computer, but not when I run it on my admin account on Windows Server 2016.
Why?
I read that one of the problems might be that the Windows Feature "Print and Document Services" needs to be installed. It is on my local machine but not on the Windows Server. Not positive this is needed. Tried to install it, and that failed. Stuck.
using (System.Printing.PrintServer ps =
new System.Printing.PrintServer(System.Printing.PrintSystemDesiredAccess.AdministratePrinter)) {
using (System.Printing.PrintQueue pq = new System.Printing.PrintQueue(ps, "Our Printer 1"
,System.Printing.PrintSystemDesiredAccess.AdministratePrinter)) {
pq.Purge();
}
}