ForumsThird-Party ApplicationsStart and stop Toodledo Sync automatically with Outlook


Start and stop Toodledo Sync automatically with Outlook
Author Message
rainergrossmann

Posted: Feb 19, 2011
Score: 0 Reference
Hello all,

I had some problems with the automatic synchronization of Chromatic Dragon's Toodledo Sync: when Outlook was closed on synchronization Toodledo Sync opened a background instance of Outlook that didn't close after sync and at the next start of Outlook some Outlook add-ins didn't start. Therefore I was looking for a possibility to start and stop Toodledo Sync with Outlook. I found that it was possible using an Outlook macro to start Toodledo Sync:

---------------Start--------------
Private Sub Application_Startup()
Shell("C:\Program Files\Chromatic Dragon\Toodledo Sync Application\SyncApp.exe")
End Sub
---------------End--------------

To stop Toodledo Sync automatically with Outlook you need pskill.exe from the Sysinternals Suite (http://technet.microsoft.com/en-us/sysinternals/bb842062). The macro to do this:

---------------Start--------------
Private Sub Application_Quit()
Shell("C:\Program Files\Sysinternals Suite\pskill.exe SyncApp.exe")
End Sub
---------------End--------------

Maybe some of you have similar problems!

Kind regards

Rainer

PS: Seems my VBA code needs improvment: the Toodledo Sync icon stays in the system tray when the program closed and does not disappear until I mouse over it. Need to find a way to close it without using pskill.exe I can't really code VBA, just trying...;)

PPS: Another problem with the code: it seems Outlook is crashing from time to time when Toodledo Sync and Outlook are closed together. I guess it would be a solution if Outlook starts a VBS-Script when closing and this script waits for about 5 seconds before terminating Toodledo Sync. Maybe with VBS there's also a solution to remove the orphaned system tray icon....


This message was edited Feb 19, 2011.
rainergrossmann

Posted: Feb 19, 2011
Score: 0 Reference
Managed to solve both problems by changing the shutdown process of Toodledo Sync.

In the Outlook Visual Basic-Editor I pointed to a VBS file outside of Outlook:

---------------Start--------------
Private Sub Application_Quit()
Shell ("wscript.exe C:\Users\delta\AppData\Local\ToodledoSyncApp\close.vbs")
End Sub
---------------End--------------

You don't need pskill.exe to stop Toodledo Sync, instead you can use taskkill.exe (c:\windows\system32\taskkill.exe). But when I force SyncApp to close with taskkill.exe (/f) the systray icon in the notification area doesn't disappear as well. It's funny, but if I try to close SyncApp.exe twice with taskkill using the parameter /t (kill process tree) the icon in the systray disappears, while the applications is still running in background. Therefore my script does this twice and then terminates SyncApp.exe using a terminate command. Unfortunately there are two ugly cmd popups when I run taskkill from the script. I found a small tool that hides these cmd-windows (http://www.uwe-sieber.de/files/hidrun.zip). And here's the script (it pauses three times in order to prevent Outlook from crashing and to run smoothly):

---------------Start--------------
WScript.Sleep 4000
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\delta\AppData\Local\ToodledoSyncApp\HidRun.exe C:\Windows\System32\taskkill.exe /IM SyncApp.exe /t"
set wshshell = nothing
WScript.Sleep 500
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\delta\AppData\Local\ToodledoSyncApp\HidRun.exe C:\Windows\System32\taskkill.exe /IM SyncApp.exe /t"
set wshshell = nothing
WScript.Sleep 500
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'SyncApp.exe'"

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
WScript.Quit
---------------End--------------

Guess some of you will smile about this unorthodox method of solving my problem with Toodledo Sync but - as said before - maybe someone has similar problems... ;)


This message was edited Feb 20, 2011.
rainergrossmann

Posted: Mar 21, 2011
Score: 0 Reference
Final update (with the above code I had random Outlook crashes when closing Outlook). This code works perfect:

Outlook VBA:

---------------Start--------------
Private Sub Application_Startup()
Shell ("C:\Program Files\Chromatic Dragon\Toodledo Sync Application\SyncApp.exe")
End Sub

Private Sub Application_Quit()
Shell ("wscript.exe C:\Users\delta\AppData\Local\ToodledoSyncApp\close.vbs")
End Sub
---------------End--------------

VBS-Script (close.vbs) to both exit Toodledo Sync and remove the Toodledo Sync icon from the notification area (running hidden with hidrun.exe - http://www.uwe-sieber.de/files/hidrun.zip; twice 'taskkill.exe /IM SyncApp.exe /t' to remove the icon and once 'taskkill.exe /IM SyncApp.exe /f" to force it to close):

---------------Start--------------
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\delta\AppData\Local\ToodledoSyncApp\HidRun.exe C:\Windows\System32\taskkill.exe /IM SyncApp.exe /t"
WScript.Sleep 500
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\delta\AppData\Local\ToodledoSyncApp\HidRun.exe C:\Windows\System32\taskkill.exe /IM SyncApp.exe /t"
WScript.Sleep 500
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\delta\AppData\Local\ToodledoSyncApp\HidRun.exe C:\Windows\System32\taskkill.exe /IM SyncApp.exe /f"
---------------End--------------


This message was edited Mar 21, 2011.
You cannot reply yet

U Back to topic home

R Post a reply

To participate in these forums, you must be signed in.