Run MEL commands when opening or closing a scene

A MEL script node lets you attach a MEL script to a scene, and have the script run whenever the scene is opened (loaded from disk) or closed (when you open another scene file or start a new scene).

See Create or edit a script node for information on creating script nodes and using them to trigger events.