Is there a way to end the session with QuickBooks / QBW32.exe so that it doesn't run in the background?

I provide technical support and some development for a number of programs that use the QuickBooks SDK to perform various functions. Lately I've noticed that when a user does the following:

Prerequisites: - QuickBooks does NOT open on the desktop and is currently not working. - My desktop application is not included in the built-in QuickBooks auto login applications.

1) Opens one of my programs.

2) Performs an action that starts a connection and session with QuickBooks.

3) The QuickBooks interface returns an error message in which you must open QuickBooks and subscribe to a company file in order to perform this action.

4) My program closes the session and connection, and then presents the user with a dialog that provides troubleshooting tips.

Result:

QuickBooks continues to run in the background as QBW32.exe even though the session and connection have been closed.

If the user then tries to open the working QuickBooks program, they receive an error message informing them that QuickBooks is already running. Then they need to open Task Manager in windows and close the running QBW32.exe file before they can successfully open QuickBooks.

I reproduced this using a very basic C # program that I wrote below.

In a test application, I am using the following steps / script:

Prerequisite: 1) The test application is NOT automatically installed to log into QuickBooks. It is set to login only if the user has the QuickBooks work program open and they have a company file open.

2) Make sure QuickBooks is NOT open prior to the test below.

Steps:

1) Open your C # test app

2) Click the "Open Connection" button. The connection must be open to the QuickBooks interface through the QBXML interval.

3) Click the Start Session button. The session must be started using QuickBooks.

4) Assuming the test prerequisites are met above, you should receive an error message returned from QuickBooks stating that the application is NOT configured to log in automatically and you will need to open QuickBooks before you can try sessions.

5) Now QBW32.exe is running in the background.

6) Press the button that says the end of the session. This should end with a session using the QuickBooks interface. The session should already have ended with the try-catch in step 3, regardless.

7) Click the button that says "Close connection". This should close all connections to QuickBooks.

8) QBW32.exe is still running in the background even though the session and connection have been terminated and closed.

9) Close the test application using the exit button.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using Interop.QBXMLRP2;

namespace Open_Connection
{

    public partial class Form1 : Form
    {

        bool sessionBegun = false;
        bool connectionOpen = false;
        RequestProcessor2 rp = null;
        string ticket;


        public Form1()
        {
            InitializeComponent();
        }

        private void End_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }

        private void OpenConn_Click(object sender, EventArgs e)
        {
            try
            {  //Start a new connection with QuickBooks
                rp = new RequestProcessor2();
                rp.OpenConnection2("", "Open Connection", QBXMLRPConnectionType.localQBD);
                connectionOpen = true;
            }

            catch (Exception connectionException)
                { //If the connection fails, close the connection to avoid the program from getting stuck in an interop error loop.
                        MessageBox.Show(connectionException.Message, "Error");
                        if (connectionOpen)
                        {
                            rp.CloseConnection();
                        }
                }
        }

        private void StartSess_Click(object sender, EventArgs e)
        {
            try
            {  //Start a new session with QuickBooks using the company file specified below.
                string ticket = rp.BeginSession(@"C:\Users\username\Documents\Quickbooks Company Files\example.QBW", QBFileMode.qbFileOpenDoNotCare);
                sessionBegun = true;
            }
            catch (Exception sessException)
            {
                //If the session fails (I.E. QuickBooks is not open with a user logged into the company file and the program is not given permission to
                //automatically log in, imeedietly end the session and close the connection.
                MessageBox.Show(sessException.Message, "Error");
                if (sessionBegun)
                {
                    rp.EndSession(ticket);
                }

                if (connectionOpen)
                {
                    rp.CloseConnection();
                }
            }
        }

        private void EndSess_Click(object sender, EventArgs e)
        {
            try
            { //End the session 
                rp.EndSession(ticket);
                sessionBegun = false;
            }

            catch (Exception ex)
            { //If a session was not started already, set the session begun flag to false to avoid getting stuck in a loop. 
                sessionBegun = false;
            }

        }

        private void CloseConn_Click(object sender, EventArgs e)
        {
            try
            { //Close the connection to QuickBooks 
                rp.CloseConnection();
                connectionOpen = false;
            }

            catch (Exception ex)
            { //If the connection was not open, set the connection open flag ot false to avoid getting stuck in a loop.
                connectionOpen = false;
            }

        }
    }
}

      

Based on the above sample program, is there anything I could do to get QBW32.exe to close on its own so that it doesn't run in the background in the above scenario?

Update: You and many other users have already tried to disable the "Save Quickbooks Running for faster startup" setting in the QuickBooks settings. This does not prevent QBW32.exe from staying open in the background after the session and connection have ended. I see this behavior happening from QB 2013 to 2015.

+3


source to share


4 answers


After further testing using the script provided by Geetanjali, I came to this conclusion:

  • QBW32.exe will only close if your program is configured in the list of integrated applications in QB to automatically log in.

  • If your program is NOT configured to log in automatically, QBW32.exe will open from the moment you start a session when you transfer the company file name, and will remain open even if you end your session and end the connection.

  • QBW32.exe does NOT start if the company file is missing at the beginning of the session.

I have confirmed several times with William on the Intuit forums that this seems to be working as intended.

To get around this, I did this in my test app:

I added an additional one if the block around the session starts to send a test connection first through an open session call without the company file specified. This causes the interface to return an error, telling me that I cannot start a session because no company files are specified and QuickBooks is not open. This causes my test app to display a message telling me to open the company file before trying again.

I suppose I can further strengthen this by adding the "use automatic login to automatic mode" and "normal mode" options so that the test connection can be skipped if desired if I really want to use automatic login.



Regardless, this is the only way to work around this scenario other than adding a block of code that kills the QBW32.exe process. This is not entirely desirable, but it is also an option.

Anyway, I hope this helps anyone who encounters this obstacle in the near future.

Update from 9/12/17:

It seems that as of QuickBooks 2016 this behavior is no longer an issue. Regardless of whether you are uploading the company file with auto login or not, when starting the session, QBW32.exe will open after the user tries to run the executable, either directly or via a desktop / launch menu shortcut (e.g. with). Interestingly, the QBW32.exe process may be running in the background due to the fact that you went to the company file without automatically logging in. However, regardless of whether the user can open QuickBooks, they will not receive a message that QuickBooks is already running.

I tested this with QuickBooks Enterprise 2016 and Enterprise 2017. All of our users who have at least QuickBooks 2016 (various editions, Pro, Premier, etc.) have also not complained about the above issue. I'm going to go to a limb here and assume that Intuit chose to fix the problem, either on purpose or unintentionally.

As such, I only recommend this approach if you or the user of your integrated app are still using a version of QuickBooks below QuickBooks 2016.

+2


source


I can tell you many years of experience using the desktop SDK with C # that you are not alone. Intuit is aware of this, and it has nothing to do with the "keep working" option. I spoke with the Intuit support staff; some think this is a bug and some think it is by design.

I have a WinForms application that is in production with QuickBooks 2006 and starting in 2011 (Enterprise 11) this hang process issue started. From 2013 even the SDK tester app ("SDK Test Plus 3") will do the same behavior as your tester app.



My application runs on many computers on my client, however the part that interacts with QB will access the QB instance on their server (not the QB installed on their PC) and I decided to use "Kill QBW32 if that doesn't close" the idea. In 2014 I changed it to communicate with QB on their desktop (since they have QB on their PC) and NOT use the kill method (because they can run QB at the same time). Because of this change, I didn't have to worry about QBW32 still working and I didn't have any problems (my client is the type to tell me).

+2


source


If your QuickBooks are running in the background, follow these steps:

Disable the Save QuickBooks for Quick Launch " option in QuickBooks 2011 or later.

  • Open QuickBooks and open your company file.
  • Choose Edit> Preferences.
  • Select the General icon in the list on the left.
  • Select the "My Settings" tab at the top.
  • Uncheck Save QuickBooks for Quick Launch.
  • Click OK.

After you close QuickBooks or restart your computer, QuickBooks will not run in the background.

0


source


I've tried the following: Open SQL Server Management Studio, run the integration pack that asks for QuickBooks (QuickBooks will start automatically in the background) and then close MS SQL completely. I can confirm that QBW32.EXE is still running and the service that called QB is no longer running.

The calling application must always close the connection. Terminating the calling application kills the application, not the connection. When using MS SQL Server, you need to bind and detach QODBC.

For example:

EXEC sp_addlinkedserver @server = N'QODBC ', @srvproduct = N'QODBC', @provider = N'MSDASQL ', @ datasrc = N'QuickBooks Data', @provstr = 'ODBC; DSN = QuickBooks data; DFQ = C: \ Program Files \ QODBC Driver for QuickBooks \ sample04.qbw; SERVER = QODBC; UseDCOM = Y; OptimizerDBFolder = C: \ Program Files \ QODBC Driver for QuickBooks \ Optimizer; OptimizerAllowDirtyReads = Y '

EXEC sp_dropserver @server = N'QODBC '

Hope this helps you.

0


source







All Articles