Q:

How to switch to Login window using obj-c in Mac OS 10.6+

I have an app and I need to switch to Login window programmatically similar to this application:
http://itunes.apple.com/us/app/lock-me-now/id464265594?mt=12
Thank you.

A:

You send an «aevtlogo» Apple Event to the loginwindow app. Look at the documentation for NSAppleEvent<Foo> classes.

A:

If you want to switch user:
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID UserID

for UserID
id -u userName

For login Window
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

