How can the bot ensure that onedrive sync is complete before logging off

How can the bot ensure that onedrive sync is complete before logging off. If the bot logs off immediately, the newly created files are not available to others with whom the folder is shared. How can we avoid this? We are moving into SharePoint foders (from the legacy file server).

1 Like

Using Image Exists Activity to check if sync is complete or not by checking oneDrive status icon in the taskbar.

Icons reference -

Sorry for the necro thread - but since this is the top Google result for this problem I figured I would share my solution.

We utilize Sharepoint/OneDrive pretty heavily for both input files for the bots as well as output files & exception screenshots. Ensuring that OneDrive is completely finished syncing either before the bot runs or before the bot is logged off was an issue of course. I originally addressed this with a delay of 10-30 seconds which for the most part would work; however not always so I needed a better solution. I’m not a big fan of using any Image activities unless absolutely necessary for accuracy reasons.

The selector used for the Element Exists:

<wnd app='explorer.exe' cls='Shell_TrayWnd' />
<ctrl name='OneDrive*Up to date' />

The “Is true” activity is simply set to check the output variable of the Element Exists.

The Retry Scope can be set up to control how long you want it to continue checking before timing out. I set it to retry 10 times with 1 second in between. Element Exists has a 30 second timeout so it will look for this to exists for 30 seconds, then continue 10 more times before timeout (so around 5 minutes total which should be more than enough time - adjust as necessary).

Since the exception for Retry Scope is very generic and unhelpful the Try Catch will allow you control what happens if it does time out. For us, I log an error message and continue processing the bot but you can throw an exception to halt processing if desired.


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.