I created a tool to be used with May, and a shelf button to go along with it. I am loading the script automatically at Maya startup in a userSetup.mel file. However, when I exit the program and restart, there is another instance of the button. It keeps creating new instances of the button. I would like to use a check such as: if (shelfButton -exists myTool), to see if the shelf button exists, but I have read that upon program termination, the shelfButtonName is not saved, so the above check would not work. I have also tried said check, and it still keeps creating the same shelf button. I have also read that I could use a dogTag flag within a check To do the same kind of thing, but have not successfully pulled this off.
So, how can I get an automatically loaded shelf button to be only created once, no matter how many times Maya is terminated and restarted.