1. seleleth's Avatar
    The Problem

    Those using the "Synchronize" area of the BlackBerry Desktop Manager may find themselves annoyed by the lack of the following feature: Automatic re-synchronization.

    There's a "synchronize automatically" check-box, which will cause a synchronization to happen when your device connects, but there's no re-synchronization after that, unless you break and remake that connection between the device and the software.

    The Solution

    As a simple solution to this, I wrote a script which closes the Desktop Manager and then re-launches it, causing a re-synchronization. I can then use this script in a Scheduled Task to re-synchronize a few times throughout the day, keeping my BB a little more up-to-date.

    Without further ado, here's the script:

    @echo off
    REM  Revision History
    REM  7/20/09, v1.0, Seth Lester Leary III
    REM    created script to close desktop manager and relaunch so it will resynch
    REM    script creates a shortcut under C:\Program Files\Research In Motion\BlackBerry
    REM    script launches shortcut instead of .exe so that command prompt closes after it runs
    REM    also created shortcut to run minimized
    REM  8/30/09, v1.1, Seth Lester Leary III
    REM    made script first check if program is running and only attempt restart if it is
    REM See if the program is running, if not, no reason to try to restart
    tasklist | find /c "DesktopMgr.exe" > %TMP%\running.tmp
    set /p RUNNING= < %TMP%\running.tmp
    if exist "%TMP%\running.tmp" del "%TMP%\running.tmp"
    if [%RUNNING%]==[0] goto end
    REM Make sure Desktop Manager is installed
    if exist "C:\Program Files\Research In Motion\BlackBerry\DesktopMgr.exe" (goto makelnk) else (goto notinstalled)
    REM Check if the shortcut file has already been created, if not, create it
    set LNKFILE=C:\Program Files\Research In Motion\BlackBerry\Desktop Manager.lnk
    if exist "%LNKFILE%" goto relaunch
    REM Create shortcut file
    set VBS=%temp%\makelink.vbs
    > %VBS% echo Dim WshShell : set WshShell = WScript.CreateObject("WScript.Shell")
    >> %VBS% echo Dim Fso : set Fso = WScript.CreateObject("Scripting.FileSystemObject")
    >> %VBS% echo set oShellLink = WshShell.CreateShortcut("%LNKFILE%")
    >> %VBS% echo oShellLink.TargetPath = "C:\Program Files\Research In Motion\BlackBerry\DesktopMgr.exe"
    >> %VBS% echo oShellLink.WindowStyle = 7
    >> %VBS% echo oShellLink.IconLocation = "C:\Program Files\Research In Motion\BlackBerry\blackberry.ico" 'Zero is the index         
    >> %VBS% echo oShellLink.Description = ""
    >> %VBS% echo oShellLink.WorkingDirectory = ""
    >> %VBS% echo oShellLink.Save
    >> %VBS% echo Fso.deleteFile("%VBS%")
    start %VBS%
    REM Relaunch desktop manager so it will resynch
    echo  Restarting BlackBerry Desktop Manager for resynchronization.
    echo  Please wait...
    taskkill /f /im DesktopMgr.exe 1>NUL 2>NUL
    REM Delay relaunch by 5 seconds
    PING -n 1 -w 5000 1>NUL 2>NUL
    goto end
    echo The BlackBerry Desktop Manager software is not installed or it is not a version I am
    echo familiar with. Please install it or modify the script to work for your version.
    Paste the contents of that code into a file in Notepad and save it with the extension ".bat" to make it executable and save it somewhere that it won't get deleted. For example, mine is named "bbsynch.bat" and it's located under "C:\Phone\", where I dump all my junk for my phone.

    Tips and Recommendations

    - For this to work at all, you need to be using the "Synchronize automatically" feature in Desktop Manager: Click Synchronize > Check the box under Synchronize automatically.
    - It's also assumed you've already installed Desktop Manager and setup synchronization and they're all working. Duh.

    - Honestly, the script could probably be done in two lines, but I went out of my way to create it so that the close/reopen process can happen in the background. To really take advantage of this, set the following option in Desktop Manager: Click Options > Check the Hide when minimized box.

    Scheduled Task
    - Configure Scheduled Tasks here: Click Start > All Programs > Accessories > System Tools > Scheduled Tasks.
    - DON'T double-click Add Scheduled Task to launch the wizard (too few options), but instead click File > New > Scheduled Task. Give the task a name.
    - Now right-click on it choose Properties. For the "Run:" field click Browse and point it to the script you created in the previous section (e.g., C:\Phone\bbsynch.bat). The "Run as:" field should already contain your username, so just leave it there. Check the box to Run only if logged on.
    - Click the Schedule tab and set it to run Daily at whatever time you like. If you want it to run at additional times check the box Show multiple schedules then add additional launch times using the New button above. (I do 11:30pm and 4:30pm--just before I go to lunch and just before I go home.) Keep in mind that it's already synching when you connect it to your PC first thing in the morning, if you do that sorta thing.

    Known Bugs

    One "issue" I'm aware of is that each time the script runs it leaves behind a ghost copy of the Desktop Manager icon in your systray, making it appear as if you have two or more copies running. This isn't really the case, and simply hovering your mouse over the ghost copies will make them disappear.

    Another thing which may be considered an issue is that if you're deliberately not running Desktop Manager currently, this script will launch it. I didn't bother to check first what your current status is and try to match it in the script. [EDIT: I changed the script to do this, actually]

    Lastly, if you're actually doing something in Desktop Manager and the script kicks off, it will obviously boot you. This may be an issue for some, but for me personally I just use minized for synching and that's it.
    Last edited by seleleth; 08-30-09 at 03:54 PM.
    07-21-09 11:56 AM
  2. seleleth's Avatar
    Update: I changed the script to check first if Desktop Manager is actually running to decide whether or not to restart it.

    It doesn't seem like many others really care about this, but I sure it this so what do I care!
    08-30-09 03:55 PM