Getting PDFCreator to run properly as a service on Windows Server 2008 proved to be a bit of trouble. Here's what I did to get things working in our environment.
Install PDFCreator in 'Server installation' mode. 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.
If installing on a Windows 2008 Terminal server be sure to go into "Install Mode" first. If the server you are using is NOT a Terminal Server, you may skip this step completely.
A Terminal Server can be placed into Install mode using one of the following methods:
++Using the Install Application on Terminal Server tool in Control Panel\\Programs.
This tool is available only when we install terminal server. It will automatically put terminal server into execute mode when application installation is complete.
++ Run Change user /install from command prompt to place the server into Install mode and install the application. After installing the application, use the Change user /execute command (or restart the server) to place the server back into Execute mode before using the application.
Change user /query command can be used to find the current mode.
When an application is installed in Install mode, HKEY_CURRENT_USER information is primarily written to the following registry key: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Terminal Server\\Install
This information is then circulated to HKEY_CURRENT_USER for each user when they log on to the Terminal Server. |
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. Since Windows 2008 Server 2008 does not have the srvany.exe you can follow the instructions here.
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, "PDFCreator", with a strong password. I next created an AD user called "PDFCreator" and made it a member of the Domain Guests group only (make sure you use a strong password, and also set the password to NEVER expire!).
Next I set the new service to run as the "PDFCreator" user.
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
You can even add a description by typing the following:
C:\\>sc description "PDFCreator" "This service allows offline printing of PDFs"
Then add the following key to your registry. You can do that easily by copy & pasting the following text into a *.txt-file and then changing the file extension to .reg. Double click on it - add to registry. Here is the text to copy into the text file:
---------------------------------------------------------------------------
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\PDFCreator\\Parameters]
"Application"="C:\\\\Program Files\\\\PDFCreator\\\\PDFCreator.exe"
---------------------------------------------------------------------------
Now save it with a .ref extension, double click and done. If you wish to manually edit the registry you can follow the registry editing instructions from KB137890 :
- Run Registry Editor (Regedt32.exe) and locate the following subkey:
HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\- From the Edit menu, click Add Key. Type the following and click OK:
Key Name: Parameters
Class :- Select the Parameters key.
- From the Edit menu, click Add Value. Type the following and click OK:
Value Name: Application
Data Type : REG_SZ
String : \\
where \\ is the drive and full path to the application executable including the extension (i.e., C:\\WinNT\otepad.exe)- Close Registry Editor.
Done. Now you have to configure the service to run as another user (as the "PDFCreator" user - be sure the user is a member of the "Domain Guests" group only, and also use a strong password and set the password to never expire).
Open \\Management\\Services\\PDFCreator. Go to the second register(Login) and change the "Login as" from the local system account to another account (use the "PDFCreator" account, make sure the user "PDFCreator" is a member of the Domain Guests group only. Also make sure you use a strong password, and also set the password to NEVER expire!). The important thing is, that the account has to have write access to the Autosave-Folder.
Almost done setting up the service. I found that it was necessary to run PDFCreator.exe and PDFSpool.exe in "Server 2003 SP1" compatibility mode. 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:
\\\\DOMAIN\\staff
-username
-Documents
-...
This setup works well for the auto-save in PDFCreator, as we can setup the auto-save directory to be:
\\\\domain\\staff\\\\Documents\\PDFCreator\\
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:
\\\\server\\PDFCreatorAutoSave\\
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! Hope this is useful and helpful for somebody out there.