I recently had users begin reporting issues where their citrix session printers were not being presented. The ultimate problem was that on the server, out of site of the user, an error 0x00000002 was being issued.
Although the problem I had was with printer autocreation when a citrix user went to print, you can see this occur in other situations as well such as attempting to directly connect to a printer when logged into a system with a desktop.
The prtprocs folder
When this error occurs, one of the first things I would check would be the %SYSTEMROOT%\System32\spool\prtprocs folder. In this folder you will find either an x64, a win32x86 folder or possibly both. In these folders you will find other folders named numerically from 1 to max(499). If prtprocs has the maximum number of folders already, then a name collision will occur internally to the spool process.
I have never really found a satisfactory answer to this question. In the end, these folders should be cleared as needed so the limit should never be reached, however, sometimes the spool service does not remove the file, probably due to locking, and the folder is left laying around until manually deleted. I presume that the reason for the 500 folder max limit is to prevent system degradation. It would have been nice however for Microsoft to put a good error message in the log indicating the real cause of the error.
The resolution to this is fairly simple. Delete all of the folders under the prtprocs folder, or at least enough of them so that new folders can be created.
In order to prevent this issue from causing me any more grief, I simply created a script in powershell that will purge folders older than 7 days. You can take a look at the script in our article, Delete Folders older than X days Recursivelyand use it if you like.