Assume you want to do some work on a remote Mac via 10.5’s Screen Sharing, but you forgot to enable Screen Sharing before you left the remote Mac. You’re now a good distance away, and apparently stuck. Fortunately, because the screen sharing system uses launchd to monitor its state, enabling and disabling is as simple as adding a file in the remote Mac’s /Libary/Preferences folder. (Note that you’ll need to be able to login to the remote Mac via ssh to run these commands on that Mac.)

$ cd /Library/Preferences
$ echo -n enabled > com.apple.ScreenSharing.launchd

To disable screen sharing:

$ cd /Library/Preferences
$ rm com.apple.ScreenSharing.launchd

If you have a Finder window open with the remote Mac selected in the Shared section, you’ll even note the icon for Screen Sharing coming and going as you do this.