command to logout user

Discussion in 'Mac Programming' started by Sunil, Nov 26, 2007.

  1. macrumors newbie

    Joined:
    Oct 6, 2005
    #1
    Hi Guys,

    Can any body tell me what is the command to logout user from system?

    I know the "reboot" and "shutdown" command but I don't know how to logout the user from system.

    Previously I was using Carbon API "SendAppleEventToSystemProcess" to restart,shutdown and logout in my Cocoa application. But now I have mad one daemon now this API is not working in my daemon. So I m looking for system commands to achieve these things.

    Thanks in advance.
    Sunil.
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    I don't know why it wouldn't work. The AE event is kAELogOut. If the Carbon functions aren't working (are you linking against Carbon.framework?), you could always use NSTask/system() and call the AppleScript directly with osascript.
     
  3. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    Is the daemon running as the user? Or as another user (non-root). I'd imagine the system would not let you log other users out unless you are the super user.
     

Share This Page