Matthew Steven Kelly

Access QuickBooks from a Windows Service (such as Apache)

December15

Quickbooks Desktop Integration

I was trying to get a Apache/PHP application to interface with Quickbooks using QBXML through the Quickbooks SDK and kept receiving the following error:

  • “Could not start Quickbooks”

When looking at the SDK log file (Located at C:\Documents and Settings\All Users\Application Data\Intuit\QuickBooks\qbsdklog.txt), I kept seeing the following error when attempting access the file:

20091215.215811 I 3416 RequestProcessor ========= Started Connection =========
20091215.215811 I 3416 RequestProcessor Request Processor, QBXMLRP2 v7.0
20091215.215811 I 3416 RequestProcessor Connection opened by app named ‘php QB via C#’
20091215.215812 E 3416 RequestProcessor QuickBooks is not running and the data file name is not provided. Cannot continue.
20091215.215812 E 3416 RequestProcessor Could not create instance of QuickBooks. hr = 80040416
20091215.215812 I 3416 RequestProcessor Connection closed by app named ‘php QB via C#’
20091215.215812 I 3416 RequestProcessor ========== Ended Connection ==========
========= Started Connection =========
Request Processor, QBXMLRP2 v7.0
Connection opened by app named 'php QB via Apache'
An internal error occured while looking for a running instance of
QuickBooks. Cannot continue. hr = 800401f3
Could not create instance of QuickBooks. hr = 8004041c
Connection closed by app named 'php QB via Apache'
========== Ended Connection ==========

If I ran my integration application through command prompt (via a .bat file) instead of Apache it worked perfectly. But Apache would not sync. I was running the Apache service as an Administrator which is I though all I needed to do. I was wrong.

Apparently accessing QuickBooks from a Windows service requires special COM permissions, because there are in-process/out-of-process Windows COM issues. We basically need to do three things: configure the COM permissions for QBXMLRP2e (installed with the Quickbooks SDK), configure Apache to run as a Windows user and configure Quickbooks to allow the application to connect.

COM Permissions configuration:

  1. Make sure the Quickbooks SDK is installed.
  2. Run command prompt and type: “C:\Program Files\Intuit\IDN\QBSDK7.0\tools\access\QBXMLRP2e\qbXMLRP2e.exe” /RegServerThis adds qbXMLRP2e to the DCOM settings list.
  3. Run “Component Services” from “Control Panel > Administrator Tools”
  4. Then from “Console Root > Computers > My Computers > DCOM Config” right click on “qbXMLRP2e” and select Properties

“Authentication level” should be set to Default

Go in Security “Launch and activation” select “Customize” and press Edit. Add the Windows user the service runs as and assign all calling rights. “Access” select “Customize” and press Edit. Add the Windows user the service runs as and assign all. “Configuration” select “Customize” and press Edit. Add the Windows user the service runs as and assign all.

Go in “Identity” tab and select “The interactive user”

Click Apply.

Apache/Quickbooks configuration:

  1. Make sure Apache is running as the user configured as the DCOM Windows user. Right click on the Apache Monitor and select Open Services. Change the “Log On As” user for the Apache service.
  2. Open Quickbooks and set it to multi-user mode. Be sure to clear out any applications in “Preference | Application Settings” first to make sure the permission settings get set correctly.
  3. Run a GUI version of your application accessing quickbooks. For example running your program through command line instead of Apache.
  4. Follow the prompts in Quickbooks to allow the application access.
  5. Run the integration through Apache and it should work now!

This took forever to figure out and hopefully it helps someone googling the error codes I was receiving.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
posted under Technology and Me

Email will not be published

Website example

Your Comment: