• Home ·
  • Programming ·
  • How to run Synergration’s OpenSync tasks as an unattended service on Windows Server 2008 R2
  • 11Dec

    How to run Synergration’s OpenSync tasks as an unattended service on Windows Server 2008 R2

    For those having issues launching OSRun.exe on a schedule on Windows Server 2008 R2, Tom and I found a work around for launching the opensync tasks unattended, essentially making OSRun.exe a service by using the task scheduler.

    A little about my environment. I'm running in a virtualized environment (Hyper-V). Windows Server 2008 R2 (with all service packs and updates), latest version of OpenSync, and Quickbooks 2012 (also with all the updates). In my scenario have two company files setup (one for development/testing purposes, and another for actual Quickbooks use). In this example, the computer name is "QB01".

    First things first, you'll need a service account to run OpenSync unattended. In this example, in Active Directory, I've created a user called [Domain Name]\QuickbooksService. This user requires Administrator rights to QB01, and even though its a ‘service’ account, must be able to logon interactively to the server running Quickbooks and OpenSync. In this scenario, QB01 is also hosting the company file; but where ever it may be hosted, create two UNC shares (one for development/testing, another for production). In my example, \\qb01\Quickbooks\Company.qbw, and \\qb01\Development\Company.qbw, have already been setup in advance, and the [DomainName]\QuickbooksService account has full access to both shares.

    Example permissions on 'QB01':

    Logon to your machine running OpenSync & Quickbooks [QB01] using [DomainName]\QuickbooksService. To test connectivity to the shares created earlier, navigate to \\qb01\Development\ and open Company.qbw… Login to quickbooks using the "Admin" account. If everything is setup properly permissions-wise, the Quickbooks company file should open. Create a *Quickbooks* user with the name "OpenSync", give it full access. Log out of "admin" user and login as "OpenSync". Then leave Quickbooks and the company file open for now.

    This example uses ms sql server as the backend; this post won't get into database setup other than you need allow the service account [DomainName]\QuickbooksService access to your database instance, and verify you can login to it from QB01. You also need to allow it to create databases for the next step (you can temporarily log in as a elevated user / sysadmin for the next step as well if you prefer — at a minimum QuickbooksService requires logon/datareader/datawriter to the database OpenSync creates; in my environment, its set to dbowner).

    Verify correct permissions and connectivity from 'QB01' to your database server (in this example 'db01\prod01', database name: "Quickbooks"):

    Using the OpenSync Configuration tool and logged on as [DomainName]\QuickbooksService, add your source company file(s). I recommend NOT using a sample company file for testing as it has issues with dates, etc – create an actual company file (disclaimer, last time I tried using OpenSync against a sample database it failed out of the gate).

    Next, create your destination database (do this as an elevated user if you don't want to give the QuickbooksService account sysadmin/create db rights on your database server).

    Lastly, create a sync task (this all depends upon your needs, try to avoid special characters in the Task Name though). For this example, the task name I have setup is "Sync All Tables – db01\prod01".

    The configuration tool should look something like this (Note: you only need one database and one company file to create a sync task):

    Right click "Sync All Tables – db01\prod01" task in the task list.. Select "Run"… Now since the company file is still open — you should get a prompt that an integrated application is trying to connect to the company file you have open. Grant it access to run without Quickbooks being open.

    Now, with the company file up, and if you haven't already, enable multi-user access on Quickbooks (you do need multi-user access enabled for the unattended setup to work properly, otherwise, you will get errors if you're logged into the same OpenSync account created earlier while the sync operation attempts to run – this should be obvious if you already running a multi-user setup).

    ** At this point, everything should work from a stand alone setup. GUI only, Interactively only. You must be able to sync without errors interactively before proceeding. **

    Onto the command line setup (this step is required for the unattended setup):

    Navigate to 'C:\Program Files (x86)\Synergration\OpenSync\'; right click and create a new text file with notepad. Add the following two lines (ScheduledTask.bat):

    "C:\Program Files (x86)\Synergration\OpenSync\OSRun.exe" Sync All Tables - db01\prod01
    taskkill /IM qbw32.exe /F

    Save the file as "ScheduledTask.txt" and rename the extension to ".bat". If you task name is different, change "Sync All Tables – db01\prod01" to your task name. Note, the task name above doesn't/cannot use quotes.

    Open a command line (you should STILL be logged in as QuickbooksService, a local administrator account on 'QB01'). Close Quickbooks and the company file. Run the following:

    C:\>"C:\Program Files (x86)\Synergration\OpenSync\ScheduledTask.bat"

    Command line output should look like:

    Running task: Sync All Tables - db01\prod01
    C:\Program Files (x86)\Synergration\OpenSync>taskkill /IM qbw32.exe /F
    SUCCESS: The process "QBW32.EXE" with PID XXXX has been terminated.

    Navigate to 'C:\OSConfig\Logs\OpenSync.Log'

    Open it using notepad. Scroll to the bottom and you should see the log of the tables that were sync'ed using the batch file you just created.

    It should look something like this:

    2012-12-11 01:09:31 0 OpenSync:Runner OSRun - Sync All Tables - db01\prod01
    2012-12-11 01:09:31 0 OpenSync:Runner Runner: Start task Sync All Tables - db01\prod01
    2012-12-11 01:09:31 0 WorkTracker Init
    2012-12-11 01:09:31 0 WorkTracker Starting task: Sync All Tables - db01\prod01
    2012-12-11 01:09:31 0 BackWorker ExecuteBackground Begin
    2012-12-11 01:09:51 0 BackWorker MakeQbConnection: Connection Opened
    2012-12-11 01:09:51 0 BackWorker FullSynch
    2012-12-11 01:09:52 0 BackWorker ..........................................................................................
    2012-12-11 01:09:55 0 WorkTracker WorkDone
    2012-12-11 01:09:57 0 BackWorker CloseQbConnection: Close Connection
    2012-12-11 01:09:57 0 BackWorker ExecuteBackground Complete
    2012-12-11 01:09:57 0 OpenSync:Runner Complete

    In addition to the log entries, when running, you should see QBW32.exe and axlbridge.exe running (and consuming resources) while its syncing. I've found it to be handy to watch the processes to troubleshoot. The OpenSync.log should contain relevant error messages if any of the above steps were missed. Here is what my processes look like during a successful sync (note, I use Process Explorer, highly recommend it, also available on Microsoft's website (by SysInternals)):

    ** At this point, everything should work from a stand alone setup. Command line only, Interactively only. You must be able to sync without errors from the command line before proceeding. **

    Onto for the unattended setup:

    Download PSTools from Microsoft's website (by SysInternals).
    Unzip to a folder on QB01. 'C:\PSTools\'

    Open Task Scheduler. Create a new task with the following:

    'General' tab:

    • Name: Quickbooks Sync
    • When running the task, use the following user account: [DomainName]\QuickbooksService
    • (Select) "Run whether user is logged on or not"
    • Configure for: Windows Vista, Windows Server 2008

    'Triggers' tab:

    • Select New…
    • On a schedule: Start "1/1/2012" at "12:00:00PM" "Daily". Recur every "1" days.
    • Repeat task every "20 minutes" for a duration of "Indefinately".
    • Stop task if runs longer than "2 hours".
    • "Enabled".
    • Select OK

    (You can customize your triggers as needed, Note: depending on your environment, 2 hours might not be long enough for the sync to complete. I recommend running manually to get an idea of how long your average sync should take)

    'Actions' tab:

    • Select New…
    • Action: "Start a program"
    • Program/script: (no quotes) C:\PsTools\psexec.exe
    • Add arguments: \\qb01 -u [domainname]\quickbooksservice -p [password] "C:\Program Files (x86)\Synergration\OpenSync\ScheduledTask.bat"

    (Note, replace [password] with the password for the account; yes, I've not found a way to NOT store the password in plain text unfortuately, instead, I isolate QB01 from access from anyone other than administrator or domain admin)

    'Conditions' tab:

    • (Select) Wake the computer to run task

    'Settings' tab:

    • (Select) Allow task to be run on demand
    • (Select) Run task as soon as posisble adter a scheduled start is missed
    • (Select) If the task fails, restart every "20 minutes"
    • Attempt to restart up to: 2 times
    • (Select) If the running task does not end when requested, force it to stop
    • If the task is already running, then the following rule applies (important): "Do not start a new instance"

    Finish creating the task…

    As you can see from the command line above, PSExec is used to Interactively run the bat file we created earlier, using the QuickbooksService account. Log out of the quickbooks service account, and login to QB01 as a different user. Open the task scheduler. Right click the task. Select "Run".. While its running, again I find it useful to watch the running processes and the user context they are running as. Here you
    should see PSExec.exe, cmd.exe, OSRun.exe, QBW32.exe, and axlbridge.exe all running under the "[DomainName]\QuickbookService] account.

    At this point you should be able to check the log in 'C:\OSConfig\Logs\OpenSync.Log', you should see your sync task running… Unattended!


Discussion 7 Responses

  1. December 11, 2012 at 2:58 pm

    Thank you for taking the time to put together this detailed instruction. I’ll give this a shot tonight, I appreciate it!

  2. December 11, 2012 at 4:38 pm

    Thanks this is great! I’ve setup my client’s server to start the OSRunner exe on startup (task scheduler), and then scheduled tasks within OSConfig; but that isn’t as stable as I want it to be. This should be much better.

  3. January 21, 2013 at 9:27 pm


  4. February 13, 2013 at 10:09 pm

    I can’t seem to get this to run correctly… It runs from a shortcut with the above commands but not from the task scheduler. The QBW32.exe launches but th axlbridge never does and the task never finishes. This only happens when being launched from the Task scheduler.

    • February 19, 2013 at 5:50 am

      Hi Brian,
      I’ve seen this before and its usually a permissions or UAC issue.
      First, make sure your starting from a clean slate (close any open processes, qbw32, etc).
      In the task scheduler, did you select Windows Vista, Server 2008 compatibility mode? Also, when running the program, are you using PSEXEC and is the user context you’re running the task as a local administrator? Are you running 2008 R2 or greater?
      If all those are double checked, open the opensync log file and let me know the output.

      You’re super close, if it works from the command line using PSEXEC you’re 95% done.

      Let me know, more details the better, but all signs point to permissions / task scheduler configuration. If it’s still not working after going over those suggestions, shoot me an email with your .bat file and the commands you’re using in the task scheduler, we might be able to narrow it down.

      PS. Sorry for the late reply

    • June 25, 2013 at 6:25 am

      I, too have had problems after working hard to figure this out.

      I’ve got the bat file working interactively in both an admin account, as well as the newly created “service” account.

      I’m also able to launch a successful sync using psexec FROM both the admin account, as well as the new “service” account, referencing the credentials of the service account.

      I’ve tried giving the job a variety of user/administrator contexts, to no avail.

      In OpenSync.log, I see
      2013-06-25 02:18:46 0 OpenSync:Runner OSRun – sync
      2013-06-25 02:18:46 0 OpenSync:Runner Runner: Start task sync
      2013-06-25 02:18:46 0 WorkTracker Init
      2013-06-25 02:18:46 0 WorkTracker Starting task: sync
      2013-06-25 02:18:46 0 BackWorker ExecuteBackground Begin
      2013-06-25 02:18:48 0 OSMonitor Loading
      2013-06-25 02:18:48 0 OSMonitor Class_Terminate
      2013-06-25 02:18:59 -2147417848 BackWorker MakeQbConnection Error: Method ‘~’ of object ‘~’ failed
      2013-06-25 02:18:59 -1 WorkTracker Method ‘~’ of object ‘~’ failed: -2147417848
      2013-06-25 02:18:59 0 OpenSync:Runner ErrorExit: Method ‘~’ of object ‘~’ failed: -2147417848
      2013-06-25 02:18:59 0 OSMonitor Class_Terminate

      The QuickBooks Log file shows
      RequestProcessor – Begin Session error = 80010105
      right after “opening the file in the DoNotCareMode”

      This thing has been driving me nuts, I’ve taken a stab at automating this several times over the past few months, but I keep reverting to having to be on call to restart the process left open in an interactive session.

  5. July 31, 2013 at 4:26 am


    Try leaving a post in the OpenSync forums. Tom – or someone else in the community – should be able to help you out.


Leave a Reply