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.
Note: You can flag certain commands via the
Security Preferences so that Maya warns you (or outright denies them) when executing scripts using this method.