Check if Excel file is being used by another BOT

Hi Team,
I am working on a usecase where 2 Bots will be accessing the same excel simultaneously so i need to apply a checkpoint that BOT should check if file is being used by another BOT. If yes, then it will wait for sometime untill file gets unlocked and then start working on that file.
Please suggest on this.

Thanks
Zara

1 Like

you have my number if u need some solution urgent then ping me there.

OOk what you do before reading the config file , first create the copy of config file then pass the copy config file name to the init module where you are reading config file…Got it? ya oper sy guzra :smirk:

Hi,

It seems like is a race condition problem. You could try to solve it in different ways, but essentially you’ll have to implement something like a semaphore:

  • Each time the bot tries to access the Excel file, it should check first for the existence of a file (.lck) that would signal the availability of the spreadsheet.
  • If the .lck file does not exist then
  • create the .lck file
  • open the Excel file
  • once you finish working with the Excel file, delete the .lck file

Or you can simply rely in a try/catch mechanism, I guess trying to access an Excel file that is being used by another user will throw an Exception.

Can you pls share any xaml you have that explains the steps provided by you.