The right way to limit gateway scripting?

I have a gateway message handler that does some extensive file scanning and folder structure work on the gateway server. I want to attach this to a button for an administrator, but also want to make sure that they cannot press or trigger it multiple times. I don’t even want two different admin users to be able to trigger it at the same time.

How could I accomplish this? I thought using some sort of lock boolean memory tag that would be turned on at the beginning of the script, and of at the end of the script/in case of error. But I was wondering if there was any other ways to handle this - limit how many instances of a gateway message handler can be running called at once?