• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Adding an application to the login items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adding an application to the login items


  • Subject: Adding an application to the login items
  • From: Bill Janssen <email@hidden>
  • Date: Wed, 3 Dec 2008 16:36:20 PST

I'm writing an installer that adds an application to the login items,
but my script (see below) keeps failing, with a bus error, like this:

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread:  0

Thread 0 Crashed:
0   com.apple.CoreFoundation      	0x96318aa7 CFStringGetLength + 39
1   com.apple.CoreFoundation      	0x963254b2 CFStringCompare + 18
2   com.apple.LaunchServices      	0x904e4b61 LSSharedFileListInsertItemURL + 73
3   _objc.so                      	0x00231855 ffi_call_SYSV + 53
4   _objc.so                      	0x00231d6c ffi_call + 147
5   _objc.so                      	0x0023f528 PyObjCFormalProtocol_ForProtocol + 1551
6   org.python.python             	0x0011fd3d PyObject_Call + 50
7   org.python.python             	0x0018db1a PyEval_EvalFrameEx + 17904
8   org.python.python             	0x0018f45b PyEval_EvalCodeEx + 1638
9   org.python.python             	0x0018f548 PyEval_EvalCode + 87
10  org.python.python             	0x001a69ec PyErr_Display + 1896
11  org.python.python             	0x001a7016 PyRun_FileExFlags + 135
12  org.python.python             	0x001a8982 PyRun_SimpleFileExFlags + 421
13  org.python.python             	0x001b3c03 Py_Main + 3095
14  org.python.pythonapp          	0x00001fca 0x1000 + 4042

Thread 0 crashed with X86 Thread State (32-bit):
  eax: 0xa07444ec  ebx: 0x96318a8a  ecx: 0x00000000  edx: 0x00000007
  edi: 0x01f10690  esi: 0x00000000  ebp: 0xbfffe8c8  esp: 0xbfffe8b0
   ss: 0x0000001f  efl: 0x00010283  eip: 0x96318aa7   cs: 0x00000017
   ds: 0x0000001f   es: 0x0000001f   fs: 0x00000000   gs: 0x00000037
  cr2: 0x00000000

Here's the script -- any advice would be appreciated!

TIA, Bill
---------------------------------------------------------------------------------

#!/usr/bin/python
# -*- mode: Python -*-

import os, sys

from Foundation import *
from AppKit import *
from LaunchServices import *

pool = NSAutoreleasePool.alloc().init()

try:
    if len(sys.argv) < 2:
        sys.stderr.write("Usage: %s APPLICATIONPATH\n" % sys.argv[0])
        sys.exit(1)
    if not os.path.isdir(sys.argv[1]):
        sys.stderr.write("Specified application %s not an application.\n" % sys.argv[1])
        sys.exit(1)
    url = CFURLRef.alloc().initWithString_(sys.argv[1])

    props = NSDictionary.dictionaryWithObject_forKey_(True, kLSSharedFileListItemHidden)

    login_items = LSSharedFileListCreate(
        kCFAllocatorDefault, kLSSharedFileListSessionLoginItems, None)

    NSLog("login_items are %s, url is %s, props are %s" % (login_items, url, props))

    v = LSSharedFileListInsertItemURL(login_items,
                                      kLSSharedFileListItemLast,
                                      None,
                                      None,
                                      url,
                                      props,
                                      None)
    NSLog("v is %s" % v)

finally:
    del pool
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Adding an application to the login items
      • From: Jason Coco <email@hidden>
  • Prev by Date: Re: Binding/KVO question
  • Next by Date: Re: Adding an application to the login items
  • Previous by thread: Re: Trouble with array controller -> array
  • Next by thread: Re: Adding an application to the login items
  • Index(es):
    • Date
    • Thread