Knowledgebase
[QODBC-Desktop] How to run QODBC applications on a repeating/nightly basis
Posted by Jack - QODBC Support on 19 October 2015 12:35 PM

How to use QODBC with Windows scheduler / How to use QScheduler with QODBC / How to run QODBC applications on a repeating/nightly basis

Problem Description 1:

My application needs to read data from QuickBooks and update data in the SQL server. Up to this, I can handle everything. But I need a solution for the task scheduler. My need is my application needs to run every hour through the task scheduler. I'm trying this, but it is giving the error message:

QuickBooks Begin Session Failed. Error = 80040408, Could not start QuickBooks.

Problem Description 2:

I have a batch file that runs a query using the QODBC driver. It ran perfectly when I logged in, but when I ran it as a scheduled task, I got this error:

Unable to connect to QuickBooks Connection String: DSN=BPCQuickBooks _PROD_batch; DFQ=; OpenMode=F; SERVER=QODBC, OLE Automation Error. The source is Microsoft OLE DB Provider for ODBC Drivers." [QODBC] Server Edition of QODBC is required to use the DCOM Servers."

SQLConnect [QODBC] QuickBooks Begin Session Failed. Error = 8004041c, An internal QuickBooks error occurred while accessing the QuickBooks company data file.
 

Problem Description 3:

There is a batch script that runs the data extraction and it works when it is run manually and we are able to generate a CSV file. However, when the batch script is scheduled to run using the task scheduler, it gives an error message 8004041d. We have followed all the solutions in the article, and we're still running into the error message when the task runs during the scheduled time in the task scheduler. We can also manually run the task in the task scheduler without an error, so it is only during the scheduled times that it gives an error, Error ID 8004041d

 

Solution : 

Windows Scheduler has changed from Desktop base to Service based from Vista or Windows 7 onwards, and the new OS has the Scheduler as Service based. 

QODBC is able to access data from QuickBooks using the QuickBooks SDK, which is an embedded feature of the QuickBooks Desktop Application.

The QuickBooks SDK requires an active desktop session (someone to be logged in) to the machine because QuickBooks is a desktop-based application.

If no one logs on to the server/machine, you will get the error "Could not start QuickBooks."

Even if you have specified the username/password and have a user logged into the machine, you may notice the same error. This is because the task executed from Task Scheduler runs as a different user / new session.



The workaround is to use a Desktop-based Based Scheduler like QScheduler https://qxl1.com/qschedule,  or http://alternativeto.net/software/task-scheduler/?platform=windows

How to use QScheduler with QODBC for repetitive or scheduled jobs

You can download QScheduler from the mentioned link:

Download QScheduler

Please refer to the following article for how to install QScheduler - https://qxl1.com/links/3047

 

After downloading QScheduler, please install it on your machine.

How to use QScheduler - https://qxl1.com/links/3059

Add a new task using the "Add" button.

Enter the task title in the "Task Name", click the "Browse" icon to select the application.

Input the start date of the task and the frequency

 

Select the file that you want to schedule & click "OPEN." In this example, I am selecting the VBS script.

Review the task details and click "Close".

 

The task will be added to the task list and will be executed.

 

 

Windows Task Scheduler (Troubleshooting)

If your company policy requires you to use the default Windows Task Scheduler, you may try the following option to see if that helps.

Error 8004041d means QuickBooks/SDK rejected the automatic login: “This application is not allowed to log into this QuickBooks company data file automatically.” In practice, this commonly happens when a scheduled task runs in a different Windows session, under a different account, or without an interactive desktop - QuickBooks (and the QuickBooks SDK) require an interactive desktop session / approved integrated application certificate for the exact user/session that is doing the BeginSession.

QuickBooks and QuickBooks SDK are not designed to run as a service.
Someone should be logged in to the Windows user session.

Run Task only when user is logged on (Interactive session), Do not use "Run with highest privileges."

Edit the scheduled task → General tab → select Run only when user is logged on (not “Run whether user is logged on or not”).

Rationale: QuickBooks and the QuickBooks SDK require an interactive desktop. If the task is started in a non-interactive session (session 0) or as SYSTEM, it can’t establish a QuickBooks SDK BeginSession. Many users fix this by keeping a user logged into the server and setting the task to run under that same user.


Use the same Windows account that was used when authorizing QODBC

The Integrated Application permission in QuickBooks is tied to the Windows user and the certificate. Make sure the scheduled task runs under the same Windows user account that you manually used when authorizing QODBC in QuickBooks. If they differ, re-authorize while logged in as the scheduled task user or change the task to run as the authorized user.



Confirm QODBC was allowed automatic login in QuickBooks Integrated Applications

In QuickBooks: Edit → Preferences → Integrated Applications → Company Preferences → find QODBC (or the exact application name shown during authorization) and ensure “Allow this application to log in automatically” is checked and the access level is appropriate (or explicitly select “Yes, always; allow access even if QuickBooks is not running” if available for your version). If you do not see the app, re-run the QODBC setup/support wizard and accept the certificate when QuickBooks prompts.


Make sure the QuickBooks company file is open and QuickBooks is running in the interactive session

For scheduled runs, quick test: log into the server interactively as the task user, open QuickBooks and the company file, then trigger the scheduled task manually (from Task Scheduler while still logged in) - if that works, but the scheduled run (when no interactive login) fails, it confirms the interactive-session issue.

(0 vote(s))
Helpful
Not helpful

Comments (6)
Ankita
26 January 2017 07:38 PM
I am using QODBC to read Quick books data in my console app. Everything works fine when I am running my code from Visual studio but when I try to run the .exe file of my application, I get this error:
'ERROR [00000] [QODBC] QB Begin Session Failed. Error = 8004041d, This applicatio
n is not allowed to log into this QuickBooks company data file automatically. Th
e QuickBooks administrator can grant permission for an automatic login through t
he Integrated Application preferences.
For more details please visit : qodbc.com/links/2147.htm
' I know every application needs to accept the certificate from quick book for accessing data and when I run the code from Visual studio the executable is different, which is registered with quick books for accessing data. How do I register my application executable file which I can run stand alone with out Visual Studio and can access quick book data? I have to schedule this application to run every day.
Jack
27 January 2017 07:36 AM
Hi Ankita,

I kindly request you to please keep QuickBooks running, logged in as Admin to your company file, try to connect using your application (i.e. executable file), it should pop-up Data Access Certificate on QuickBooks, Please accept the Certificate then try again.

If you are still facing issue, I kindly request you to please raise a support ticket to the QODBC Technical Support department from below mentioned link & provide requested information:

http://support.flexquarters.com/esupport/index.php?/Tickets/Submit

We may need the following information, I kindly request you to attach below listed files when replying to the ticket.
1) Screenshot of QODBC Setup Screen -- > About
2) Screenshot of the issue you’re facing.
Share Entire Log Files as an attachment in text format from
3) QODBC Setup Screen -- > Messages -- > Review QODBC Messages
4) QODBC Setup Screen -- > Messages -- > Review SDK Messages

Ankita
03 February 2017 02:28 PM
Thank you Jack. It worked.
Ankita
03 February 2017 09:58 PM
Hello Jack,

From the solutions given to problems regarding 'Scheduled task using QODBC driver', I know Windows Task Scheduler cannot be used to schedule applications using QODBC drivers to read quick book data. But the workaround suggested by using desktop based scheduler like KA FireTask, etc, can I schedule a application (using QODBC drivers to read data) to run under a default account even when user is not logged in?
Jack
06 February 2017 11:34 AM
Hi Ankita,

I would like to inform you that QuickBooks required Active Desktop Session for running. You need to log in to server & run QuickBooks for work with QODBC. If no one logged on server, you will get error "Could not start QuickBooks", So the server need Active Desktop Session & QuickBooks in running mode for proper functionality.

So you need to Keep QuickBooks running (No need to log in to the company file, just keep QuickBooks window open) and try to connect.

If you are still facing issue, I kindly request you to please raise a support ticket to the QODBC Technical Support department from below mentioned link & provide requested information:

http://support.flexquarters.com/esupport/index.php?/Tickets/Submit

We may need the following information, I kindly request you to attach below listed files when replying to the ticket.
1) Screenshot of QODBC Setup Screen -- > About
2) Screenshot of the issue you’re facing.
Share Entire Log Files as an attachment in text format from
3) QODBC Setup Screen -- > Messages -- > Review QODBC Messages
4) QODBC Setup Screen -- > Messages -- > Review SDK Messages

Jack
14 September 2017 11:44 AM
The desktop-based scheduler KA Firetask is not available now. So you can use Z-Cron scheduler (http://www.z-cron.com/download.html) for scheduling job.
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please complete the captcha below (we use this to prevent automated submissions).