Some test text!

Working with Windows services

In this document
chevron_rightConverting to PDF inside a Windows service
chevron_rightEnsuring filesystem access

linkConverting to PDF inside a Windows service

Windows Service applications run unattended without any form of user interaction. By default, Windows Service applications use the “LOCAL SYSTEM” or “LOCAL SERVICE” account. These accounts have:

  • Very limited amount permissions for tasks needing registry access
  • Access to some system folders.

Due to their nature of being unattended, it is understandable that these applications have limited permissions to mitigate security risks. To be able to successfully convert to PDF, from a Windows service, it is necessary to ensure that the service has the necessary permissions and access to perform the conversion.

linkEnsuring filesystem access

When using Microsoft Office Excel, before the application actually opens, the desktop folder of the user must be present. For example, when user “Bob” opens Microsoft Office Excel, Excel requires the folder “C:\Users\Bob\Desktop” to be both present and accessible before the actual Excel windows will show in Bob’s screen. Similarly, for Windows Service, Excel expects “LOCAL SYSTEM’s” or “LOCAL SERVICE’s” desktop folder to be present and accessible before the process will continue.

Local System or Local Service’s desktop folders can be found in the following locations:

  • C:\Windows\System32\config\systemprofile\Desktop
  • C:\Windows\SysWOW64\config\systemprofile\Desktop (only on 64-bit Windows)

In order for ToPdf to function with “LOCAL SYSTEM” or “LOCAL SERVICE”, the desktop folders above must first be created. It is also important to make sure that these system accounts have access to the desktop folders. It is normally not necessary to set the permissions explicitly because the Desktop will inherit them from the systemprofile folder.

Another thing to keep in mind when using 64-bit Windows: 32-bit applications use the "C:\Windows\SysWOW64" folders, while 64-bit applications use "C:\Windows\System32".

  • If a 64-bit Microsoft Office version is installed on a 64-bit Windows, the required desktop folder will be:
    C:\Windows\System32\config\systemprofile\Desktop
  • If a 32-bit Microsoft Office version is installed on a 64-bit Windows, the required folder will be:
    C:\Windows\SysWOW64\config\systemprofile\Desktop

If using system accounts does not work with ToPdf even after the above desktop folders are created, an alternative would be to use a user account for the Windows Service instead. There may be some cases where the PDFTron PDFNet printer will not work with system accounts because the printer requires access to the registry. In such cases, user accounts normally work better.