Enabling Assistive Devices programmatically for UI Automation on the Mac

As part of our effort to test Windows Presentation Foundation Everywhere (WPF/E) on the Mac, I'm working on a UI Automation tool to drive WPF/E apps from out of process.  In the anticipation that WPF/E will eventually support Accessibility (and I assure you it will!), we need to programmatically turn on the checkbox in Mac OS X to enable the AXAPI (Mac's technology similar to MSAA).

It turns out this option in the UI is controlled by the magical file: "/private/var/db/.AccessibilityAPIEnabled".  If this file exists, the checkbox is checked, and we can drive applications through AXAPI.  If you delete the file, then accessibility is obviously disabled.  This operation is reversible on the fly and does not appear to require a reboot to swap, which is really handy.

The final requirement is to create this file programmatically, in my case, through a shell script... although I'm sure there's a cleaner, more involved way to do it.  This is the quick and (very) dirty way.  Put the following script into a file, and execute it from a Mac Terminal window with "sh myFile".

cd /private/var/db
Echo “$ADMINPWD” | sudo touch .AccessibilityAPIEnabled

Of course, emitting the admin password in a text file is what really constitutes "dirty", but it suits my immediate purposes.  Someone on the Mac Office team suggested compiling this into an app and setting the "sticky" bit by installing with "1755 permissions" so I don't have to embed the admin pword in my script, which sounds like a good next step.  There are many, many more issues to go =).  I'm still very new to automation issues on the Mac.  We have experts in the company, but having me bother them isn't always optimal, so I'd definitely be interested in any good online resources that you community folks have in mind.  Any help is greatly appreciated!