Ideally you would control who can run the script using Accounts&Privileges under File>Manage>Accounts&Privileges.
You could then set your script into an If check:
If ( Get(AccountName) = "jmoorma2" )
Insert the script here
The If will avoid the annoying "your privileges do not allow this" pop-up, but the true security is to be had via Privilege settings.
In addition to what Ninja wrote, I have a number of buttons that can only be used by people (managers) logging in with certain account privileges.
But, what I also did was to use conditional formatting so that the buttons disappear (text turns to same color as background) when somebody uses the file who does not have the necessary account privileges to access the buttons. That way they don't even know the button is there.
Thanks! I was trying to figure it out all day and trying to change privileges would have been a major headache as we are on a shared server with over 100 people. Thanks again!!!
Careful, such a hidden button can still be clicked and may still turn your cursor pointer into a hand when you hover over it.
Your script will still need to check for an account name or privilege set name (a better option if you want to enable a button for a group of users.) to keep it from executing or triggering the accounts and privileges error dialog.
Thanks for the warning. I did't use the hidden button just made the script with the button to allow on my account name to be able to access the script/use the button.