Skip to content

Instantly share code, notes, and snippets.

@eahrold
Last active January 3, 2016 04:49
Show Gist options
  • Save eahrold/8411380 to your computer and use it in GitHub Desktop.
Save eahrold/8411380 to your computer and use it in GitHub Desktop.
Global Login Item are deprecated remove them with this
#!/usr/bin/python
'''
Pass in the Full path to the application as the first arg
for example /usr/local/sbin/rm_global_login.py /Applicaitons/MunkiMenu.app
'''
import os
import sys
from LaunchServices import *
path = sys.argv[1:]
def main():
if not path or not os.path.exists(path[0]):
print 'no application at that path'
sys.exit(1)
loginItem = "file://%s" % path[0]
loginItems = LSSharedFileListCreate(None, kLSSharedFileListGlobalLoginItems, None);
loginItemsArray,seed = LSSharedFileListCopySnapshot(loginItems, None);
for item in loginItemsArray:
v,url,ref = LSSharedFileListItemResolve(item,0, None, objc.NULL)
url = "%s" % url
print url
if url == loginItem:
print 'removing %@' % url
LSSharedFileListItemRemove(loginItems,item)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment