Problem With Global Login Items

Discussion in 'Mac Programming' started by MitchBall, Sep 15, 2014.

  1. MitchBall macrumors newbie

    Joined:
    Sep 15, 2014
    #1
    I have searched everywhere for how to set up login items and ran different scripts in terminal, applescript, and xcode.

    However none have seemed to work, what needs to be done is a global login item needs to run a .app file which maps 2 network drives, and another .app which runs printer software, however none of the scripts i have used have worked.

    If anyone could provide a link, or code, or any help or how to, it would be highly appreciated.

    Thanks!
     
  2. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    Please provide some links, or code from the things you tried that didn't work.
     
  3. MitchBall, Sep 15, 2014
    Last edited by a moderator: Sep 15, 2014

    MitchBall thread starter macrumors newbie

    Joined:
    Sep 15, 2014
    #3
    http://www.macinstruct.com/node/427

    http://forums.macrumors.com/showthread.php?t=1010342

    http://stackoverflow.com/questions/9483959/osx-10-8-loginitems

    Also; I have tried codes such as -

    Code:
    -(void) addAppAsLoginItem{
    	NSString * appPath = [[NSBundle mainBundle] bundlePath];
    
    	// This will retrieve the path for the application
    	// For example, /Applications/test.app
    	CFURLRef url = (CFURLRef)[NSURL fileURLWithPath:appPath]; 
    
    	// Create a reference to the shared file list.
            // We are adding it to the current user only.
            // If we want to add it all users, use
            // kLSSharedFileListGlobalLoginItems instead of 
            //kLSSharedFileListSessionLoginItems
    	LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL,
                                                         kLSSharedFileListSessionLoginItems, NULL);
    	if (loginItems) {
    		//Insert an item to the list.
    		LSSharedFileListItemRef item = LSSharedFileListInsertItemURL(loginItems,
                                                         kLSSharedFileListItemLast, NULL, NULL,
                                                         url, NULL, NULL);
    		if (item){
    			CFRelease(item);
                    }
    	}	
    
    	CFRelease(loginItems);
    }

    Nothing Still seems to work, we are trying to run this in a school for users to log on and have all drives ready for use, we are running OS X 10.9.4.

    Thanks in advance.
     

Share This Page