Skip navigation.
 
mlRe: Starting as Startup Item?
FROM : Mark Munz
DATE : Sun Dec 05 19:19:47 2004

I don't know the reason you need to know the difference between 
starting up as a login or not, but be careful, because this solution 
will only "mostly" work.

Scenario: User adds application to Startup Items then launches your 
Application from Finder.

You will be listed in the startup items, but you didn't start at 
Startup.

Depending on the original need, this solution may be "good enough", but 
as always, it is good to know of potential cases where it may fail so 
that you can deal with it appropriately.

Mark Munz

On Dec 5, 2004, at 12:03 AM, Darkshadow wrote:

> You can check the loginwindow.plist file, and see if your application 
> is listed there.  This code should do it.  Note that the autolaunched 
> applications could be moved in the future to some other plist, or even 
> not saved (like this) at all, but it has been in the loginwindow.plist 
> file since 10.1 (I'm not sure about 10.0; I never looked back then). 
> Keep that in mind if you decide to use this.  Also, I think the keys 
> had different names in 10.1, so if you're looking for compatibility 
> with 10.1, you may want to check that out.
>
> - (BOOL)isInAutoLaunchDictionary
> {
>     NSString 
> *loginwindowPlist=[@"~/Library/Preferences/loginwindow.plist" 
> stringByExpandingTildeInPath];
>     NSDictionary *autoLaunchedApps=[NSDictionary 
> dictionaryWithContentsOfFile:loginwindowPlist];
>     NSArray *appsArray=[autoLaunchedApps 
> objectForKey:@"AutoLaunchedApplicationDictionary"];
>     NSEnumerator *anEnum=[appsArray objectEnumerator];
>     id anObject;
>
>     while ((anObject=[anEnum nextObject])) {
>         if ([[[NSBundle mainBundle]bundlePath] isEqualToString:[anObject 
> objectForKey:@"Path"]]) {
>             return YES;
>         }
>     }
>
>     return NO;
> }
>
> Darkshadow (aka Mike Nickerson)
>
> On Dec 4, 2004, at 3:20 AM, Mihkel Tammepuuu wrote:
>

>> How can an application determine if it was launched as a Startup Item 
>> on logging in to Mac OS or a usual way like (double)clicking it's 
>> icon?
>>
>> //
>> Mihkel Tammepyy

>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/
> <email_removed>
>
> This email sent to <email_removed>

Related mailsAuthorDate
mlStarting as Startup Item? Mihkel Tammepuuu Dec 4, 09:20
mlRe: Starting as Startup Item? M. Uli Kusterer Dec 4, 09:28
mlRe: Starting as Startup Item? Finlay Dobbie Dec 4, 19:15
mlRe: Starting as Startup Item? Mihkel Tammepuuu Dec 4, 20:16
mlRe: Starting as Startup Item? Darkshadow Dec 5, 07:03
mlRe: Starting as Startup Item? Mark Munz Dec 5, 19:19
mlRe: Starting as Startup Item? Sean McBride Dec 11, 18:45