5

I have created an app, that sets itself to launch at Login using SMLoginItemSetEnabled. Here is the code it uses. My question is, how can I manually remove this app from launching at login?

The app does not show under "Login Items", or /Library/LaunchAgents, or /Library/LaunchDaemons or in the /Users/username/Library/LaunchAgents, or /Users/username/Library/LaunchDaemons folders. I looked around in /Library/Preferences and PreferecePanes, but I found nothing. The app does load on login.

  • if you remove the app (from the disk) what does the Console say? – Martin Marconcini Feb 12 '13 at 1:48
  • If I remove the app (even when it's not running), I can move it to Trash, but when I try to empty Trash, it won't delete the App. – Tarandeep Gill Feb 12 '13 at 14:09
  • Did you ever find a solution for this? Wondering the same. – Klaas Aug 7 '16 at 14:00
  • Seems like some are listed here: /var/db/com.apple.xpc.launchd/disabled.$UID.plist – Klaas Aug 7 '16 at 14:14
2

You should be able to stop and remove the helper from launchd from the command line. Open up Terminal.app and do

launchctl list | grep -i com.your.helper

Look once you've located the job_label in the third column, you can run

sudo launchctl stop com.your.helper
sudo launchctl remove com.your.helper

The manual for launchctl can be found here

0

And if you added it with a helper, like you said, then you should be able to see it in the plist (I think).

Take a look at this:

-(BOOL)appIsPresentInLoginItems
{
    NSString *bundleID = @"com.madebynotion.myLoginHelper";
    NSArray * jobDicts = nil;
    jobDicts = (NSArray *)SMCopyAllJobDictionaries( kSMDomainUserLaunchd );
    // Note: Sandbox issue when using SMJobCopyDictionary()

    if ( (jobDicts != nil) && [jobDicts count] > 0 ) {

        BOOL bOnDemand = NO;

        for ( NSDictionary * job in jobDicts ) {

            if ( [bundleID isEqualToString:[job objectForKey:@"Label"]] ) {
                bOnDemand = [[job objectForKey:@"OnDemand"] boolValue];
                break;
            } 
        }

        CFRelease((CFDictionaryRef)jobDicts); jobDicts = nil;
        return bOnDemand;

    } 
    return NO;
}

source: http://blog.mcohen.me/2012/01/12/login-items-in-the-sandbox/

  • 1
    Thanks for the reply Martin. But I am looking for a way to remove it manually (without the use of program). Where is this PList file stored on the system? – Tarandeep Gill Feb 12 '13 at 2:02
  • Oh no problem. The reason why I was adding the code is to see what it's doing. It has got to be in the sanboxed directory of your app perhaps… but I never thought about it. I'll take a look tho' – Martin Marconcini Feb 12 '13 at 21:31
0

Login items are stored in ~/Library/Preferences/com.apple.loginitems.plist, and can be manually managed in System Preferences -> Users & Groups -> your user account in the sidebar -> Login Items tab.

  • That's the issue. The app does not show under the Login Items tab, and it is not listed in ~/Library/Preferences/com.apple.loginitems.plist either! – Tarandeep Gill Feb 12 '13 at 3:11
0

If I remove the app (even when it's not running), I can move it to Trash, but when I try to empty Trash, it won't delete the App.

When it is in the trash, restart the mac in single user mode (start while holding cmd+s): this will open in a Terminal window, run

sudo rm -Rf ~/.Trash/*

and press enter, then restart normally.

0

You can stop the item from launching with launchctl disable gui/$UID/bundle-id.

If you don't know the bundle ID, you can find it by typing launchctl list. That will list all processes running under your user, with their PIDs in the first column. So, if you saw this:

$ launchctl list
-   0   com.apple.SafariHistoryServiceAgent
277 0   com.apple.Finder
-   0   com.apple.quicklook
-   0   com.apple.parentalcontrols.check
[…]
189 0   com.example.ExampleDaemon
-   0   com.apple.java.InstallOnDemand

…you could use Activity Monitor to confirm that the unwanted app's PID is 189, which makes its bundle ID com.example.ExampleDaemon. Then:

launchctl disable gui/$UID/com.example.ExampleDaemon

That's it. There is still a record of the login item on disk, just disabled. If you want to purge it, or just want to learn more, read on.


Counterintuitively (but amusingly?), the list is saved here:

/var/db/com.apple.xpc.launchd/disabled.$UID.plist

That file will look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.example.ExampleDaemon</key>
    <false/>
</dict>
</plist>

Yes, the false means that an app with that bundle id should be launched at startup. After running launchctl disable, the false will change to a true. (As far as I can tell, launchd doesn't write these files right away, so you may not see this until you reboot.) You can see the disabled items with this command:

launchctl print-disabled gui/$UID

There's also some extra info about each login item stored here, but removing it won't stop the item from launching:

/var/db/com.apple.xpc.launchd/loginitems.$UID.plist

Any changes you make while the system is running will be overwritten when you shut down/restart. So, as far as I can tell, the only way to completely remove an item from disabled.$UID.plist is to reboot in single user mode and make the edits there. Even without having run launchctl disable, removing a key/false pair from this file stops the app from launching at login. I'm not going to include instructions for editing these files in single user mode in this answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .