PDFCreator as a Service

Last PDFCreator version tested: 1.0.1

PDFCreator is a great tool for users you just need to quickly convert a document into pdf format.  Getting it to run properly as a service on Windows Server 2008 proves to be a bit of trouble.  In fact, despite all the PowerShell info and the other topics I write about, over 1/2 the traffic on my blog is about getting this combination to work!  So here's the latest update for PDFCreator version 1.0.1.

Install PDFCreator in 'Server installation' mode.  With version 0.98 I found that if data execution prevention is enabled, PDFCreator needs to be added to the exception list (DEP hides a little bit under Control Panel - System - Advanced system settings - Advanced - Data Execution Prevention).  However, with version 1.0 and moving forward, I have found that this is not true which makes our setup easier!

Next we need to get srvany.exe from the Windows Server 2003 Resource Kit.  I decided to put it in \Program Files\oldResourceKitTools.  This article explains how to use instsrv.exe to setup a custom service that uses srvany.exe to run what we want.  Trouble is instsrv.exe doesn't work very well on Server 2008.  Thankfully we can use sc.exe to create the service in a similar way.

However, before we create the service we have to decide what credentials to have the service run as.  Depending on your environment running as the local system (the default) may be sufficient.  If PDFCreator will need to save files anywhere other than the local system we'll  need to choose either Network Service, or create a domain user for the service.  As I like to be able to control specific permissions I created a new domain user, svc-pdfcreator, with a strong password.

Armed with that information we can now create the service with the sc command:

C:\> sc create pdfcreator start= auto binPath= "C:\Program Files\oldResourceKitTools\srvany.exe" DisplayName= "PDFCreator" obj= DOMAIN\User password= password

We can double check that the service was created successfully by using sc query:

C:\>sc query pdfcreator

SERVICE_NAME: pdfcreator
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Now we need to follow the registry editing instructions from KB137890 :
  1. Run Registry Editor (Regedt32.exe) and locate the following subkey:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<My Service>
  2. From the Edit menu, click Add Key. Type the following and click OK:

    Key Name: Parameters
    Class :<leave blank>
  3. Select the Parameters key.
  4. From the Edit menu, click Add Value. Type the following and click OK:

    Value Name: Application
    Data Type : REG_SZ
    String : <path>\<application.ext>

    <path>\<application.ext> is the drive and full path to the application executable including the extension (i.e., C:\WinNT\Notepad.exe)
  5. Close Registry Editor.
Almost done setting up the service.  With version 0.98 I found that it was necessary to run PDFCreator.exe and PDFSpool.exe in "Server 2003 SP1" compatibility mode.  Once again, this appears to have been resolved with version 1.0+, so we don't have to worry about compatibility settings!  But if you're using a version prior to 1.0, go to the compatibility tab on the properties of each executable and check "Run this program in compatibility mode for:" and select "Windows Server 2003 (Service Pack 1)".

That's it!  Test the service either by running "net start pdfcreator" or from the services mmc snap-in.  If all goes well it should start successfully.

The last piece of the puzzle is setting up Auto-save in PDFCreator itself.  Run "PDFCreator Settings" from the start menu and click the 'Auto-save' link on the left side of the window.  What you setup here will vary depending on your environment.  We have a standardized structure for our users:

This setup works well for the auto-save in PDFCreator, as we can setup the auto-save directory to be:

You may have to get creative with the auto-save path if your userdata paths aren't uniform across the users that have access to the PDFCreator printer.  We could probably solve the issue by setting up a shared folder like:

Wherever you decide to have PDFCreator save its output, make sure that the account the service runs as has permissions to create and modify files and your users have at least read access.

That's it!  As always, feel free to contact me with questions and comments.