clawsoftware / clawPDF

Open Source Virtual (Network) Printer for Windows that allows you to create PDFs, OCR text, and print images, with advanced features usually available only in enterprise solutions.
https://github.com/clawsoftware/clawPDF
GNU Affero General Public License v3.0
710 stars 152 forks source link

Local spools located in C:\AppData\ instead of %username% #98

Open gabrielweyerjb opened 1 year ago

gabrielweyerjb commented 1 year ago

When I start my exe by double-clicking on it in Windows Explorer, printing is working as expected. When the exe is started by the Task Scheduler, the printing fails. The exe is running under the same user in both cases.

Working logs

2023-06-02 11:42:41.1337 [Debug] 14220-1 (ProgramThread) clawSoft.clawPDF.JobInfoQueue..ctor: Spool folder is 'C:\Users\user_s6svr01\AppData\Local\Temp\clawPDF\Spool' 
2023-06-02 11:42:41.2037 [Debug] 14220-1 (ProgramThread) clawSoft.clawPDF.JobInfoQueue.Init: Temp folder is 'C:\Users\user_s6svr01\AppData\Local\Temp\clawPDF\Temp' 
2023-06-02 11:42:41.2037 [Debug] 14220-1 (ProgramThread) clawSoft.clawPDF.Startup.MaybePipedStart.Run: Starting attempt 1:  
2023-06-02 11:42:41.2167 [Debug] 14220-1 (ProgramThread) clawSoft.clawPDF.Startup.MaybePipedStart.TrySendPipeMessage: Found another running instance of clawPDF, so we send our data there 
2023-06-02 11:42:41.2167 [Debug] 14220-1 (ProgramThread) clawSoft.clawPDF.Startup.NewPrintJobStart.EnsureJobFileIsInSpoolPath: JobInfo file from printer is not in our spool folder (C:\Users\user_s6svr01\AppData\Local\Temp\clawPDF\Spool) - we'll move it there 
2023-06-02 11:42:41.2407 [Debug] 14220-1 (ProgramThread) clawSoft.clawPDF.Startup.MaybePipedStart.TrySendPipeMessage: Pipe message successfully sent 
2023-06-02 11:42:41.2407 [Debug] 14220-1 (ProgramThread) clawSoft.clawPDF.Startup.MaybePipedStart.Run: TrySendPipeMessage: True 
2023-06-02 11:42:41.2407 [Debug] 14220-1 (ProgramThread) clawSoft.clawPDF.Threading.ThreadManager.WaitForThreads: Waiting for all synchronized threads to end 
2023-06-02 11:42:41.2407 [Debug] 14220-1 (ProgramThread) clawSoft.clawPDF.Threading.ThreadManager.WaitForThreads: All synchronized threads have ended 
2023-06-02 11:42:41.2467 [Debug] 14220-1 (ProgramThread) clawSoft.clawPDF.Threading.ThreadManager.Shutdown: Shutting down the application 
2023-06-02 11:42:41.2467 [Debug] 14220-1 (ProgramThread) clawSoft.clawPDF.Threading.ThreadManager.Shutdown: Exiting... 
2023-06-02 11:42:41.2677 [Trace] 11288-8 (ProcessingThread) clawSoft.clawPDF.Workflow.WorkflowFactory.CreateWorkflow: Creating Workflow 
2023-06-02 11:42:41.3447 [Debug] 11288-8 (ProcessingThread) clawSoft.clawPDF.Workflow.WorkflowFactory.CreateWorkflow: Profile: <Default Profile> (GUID DefaultGuid) 
2023-06-02 11:42:41.3637 [Debug] 11288-8 (ProcessingThread) clawSoft.clawPDF.Core.Jobs.AbstractJob.NumberOfPagesFromSourceFiles: Number of pages from source files: 1 
2023-06-02 11:42:41.3637 [Debug] 11288-8 (ProcessingThread) clawSoft.clawPDF.Core.Jobs.AbstractJob.get_NumberOfCopies: Number of copies from source files: 1

Non-working logs

2023-06-02 11:45:14.1732 [Debug] 11944-1 (ProgramThread) clawSoft.clawPDF.JobInfoQueue..ctor: Spool folder is 'C:\Users\user_s6svr01\AppData\Local\Temp\clawPDF\Spool' 
2023-06-02 11:45:14.2452 [Debug] 11944-1 (ProgramThread) clawSoft.clawPDF.JobInfoQueue.Init: Temp folder is 'C:\Users\user_s6svr01\AppData\Local\Temp\clawPDF\Temp' 
2023-06-02 11:45:14.2522 [Debug] 11944-1 (ProgramThread) clawSoft.clawPDF.Startup.MaybePipedStart.Run: Starting attempt 1:  
2023-06-02 11:45:14.2522 [Debug] 11944-1 (ProgramThread) clawSoft.clawPDF.Startup.MaybePipedStart.TryStartApplication: Starting pipe server 
2023-06-02 11:45:14.2522 [Debug] 11944-1 (ProgramThread) clawSoft.clawPDF.Threading.ThreadManager.StartPipeServerThread: Starting pipe server thread 
2023-06-02 11:45:14.2652 [Debug] 11944-1 (ProgramThread) clawSoft.clawPDF.Startup.MaybePipedStart.TryStartApplication: Reloading settings 
2023-06-02 11:45:14.3462 [Debug] 11944-1 (ProgramThread) clawSoft.clawPDF.Startup.MaybePipedStart.TryStartApplication: Finding spooled jobs 
2023-06-02 11:45:14.3462 [Debug] 11944-1 (ProgramThread) clawSoft.clawPDF.JobInfoQueue.FindSpooledJobs: Looking for spooled jobs in 'C:\Users\user_s6svr01\AppData\Local\Temp\clawPDF\Spool' 
2023-06-02 11:45:14.3462 [Debug] 11944-1 (ProgramThread) clawSoft.clawPDF.JobInfoQueue.FindSpooledJobs: Searching for spooled jobs 
2023-06-02 11:45:14.3462 [Debug] 11944-1 (ProgramThread) clawSoft.clawPDF.Startup.NewPrintJobStart.EnsureJobFileIsInSpoolPath: JobInfo file from printer is not in our spool folder (C:\Users\user_s6svr01\AppData\Local\Temp\clawPDF\Spool) - we'll move it there 
2023-06-02 11:45:14.3622 [Error] 11944-1 (ProgramThread) clawSoft.clawPDF.Startup.MaybePipedStart.TryStartApplication: There was an error while starting the application System.UnauthorizedAccessException: Access to the path is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost)
   at clawSoft.clawPDF.Startup.NewPrintJobStart.MoveSpoolFile(String infFile, String spoolFolder, ApplicationSettings applicationSettings)
   at clawSoft.clawPDF.Startup.NewPrintJobStart.EnsureJobFileIsInSpoolPath()
   at clawSoft.clawPDF.Startup.NewPrintJobStart.StartApplication()
   at clawSoft.clawPDF.Startup.MaybePipedStart.TryStartApplication()

The access denied happens when ClawPDF tries to create a file in C:\AppData\Local\Temp\clawPDF\Spool. When printing is working, this directory is not used.