Applescript "deamon" on system startup or login item

Hello:
I wrote an AppleScript script and saved it as an Applet that needs to run in the background whenever the system is up.
1/ I tried to set it as a startup item, so that it would start running as soon as the Mac is on -- however without success. I did not find out what the proper way is of doing this.
2/ Then I tried to set it as a login item for each user. This is not as good, but I thought it may an alternative, 'buying me some time' to figure out how to do it properly as a system startup item. Launching the app works fine, but the user cannot log off again, because the system cannot seem to quit the script. So I have to stop the process in Activity Monitor, obviously not a solution.
3/ Also, I would prefer the script to not show up in the Dock.
Any help is appreciated, especially on question #1. 
Thanks,
HAL

Hello twtwtw:
Thank you for your excellent advice and sorry for my ridiculous late reply.
Your first suggestion works smoothly, adding the "Application is agent" key to the Info.plist file via Xcode hides the app.
Also, I created the launchd launchagent plist file as you suggested and put it into /Library/LaunchAgents. The file name is irrelevant, I presume. The app itself is now in a subdirectory of /Library/StartupItems, which I thought is the appropriate place.
However, the app does not start, when a user logs in, instead I do have a permission problem with the following entry in Console:
Apr 29 19:08:31 My-Conputer com.apple.launchd.peruser.501[114] (...[277]): posix_spawn("/Library/StartupItems/SlowFan/SlowFan.app", ...): Permission denied
Apr 29 19:08:31 My-Computer com.apple.launchd.peruser.501[114] (...[277]): Exited with code: 1
So I have 4 questions:
1/ I do not understand why I am getting the permission error, because "System" has read & write access to the folder as well as on the application. What am I missing? My own user also has the same read & write permission, so if I start it myself, it works fine.
2/ Just out of curiosity, do you know what is the difference between the files in "/Library/LaunchAgents" and "/Library/LaunchDaemons"?
3/ In addition, what I really wanted was to launch the app, when the system starts, even if no user is logged in. Is this possible?
4/ If not, how do I avoid that the app runs multiple times in each user context? I want it to run once only.
As usual, any hint is appreciated!
Thanks,
HAL

Similar Messages

  • I cant access System Preferences»Accounts»Login Items

    I cant access System Preferences»Accounts»Login Items can anyone help?
    I have two admin accounts on this machine. One local admin account that does not have this problem, and one mobile admin (remote access) user account that I use for all work. I have repaired permissions and disk from startup cd. I have deleted the following files-
    com.apple.preferencepanes.cache
    com.apple.preferencepanes.searchindexcache
    com.apple.systempreferences.plist
    Nothing seems to work. Any suggestions?

    What do you mean that you can't access the login items?
    1) No tab for login items in Accounts?
    - Are you logged in as that user?
    2) Tab exists but doesn't switch to it when clicked?
    3) Can see login items, but can't do anything with them?

  • All Network Volumes set as Login Items open in Finder on EVERY startup

    ...after updating to 10.5.8
    I have a Mac running on an otherwise all PC network. Before updating to 10.5.8 I had 5 network volumes set to "connect" on startup automatically (System Prefs / Accounts / Login Items). This worked perfectly and connected to these volumes silently without me having to ever worry about it. I didn't even have to check the "Hide" boxes.
    After updating to 10.5.8 however, it became completely annoying. Now it still connects to these volumes, but opens up every single one in Finder upon every startup. That's 5 windows I have to close every time I startup my computer. It may not sound like the worst thing in the world, but mind you I have to log out and back in every day for work. Even checking the "Hide" checkboxes don't do anything.
    Anybody experiencing the same problem? Anybody know a workaround or fix? My company has a rather large and complex network so staying connected to certain folders that I use is a must. Thanks.
    Screenshots:
    Login Items - http://img.photobucket.com/albums/v326/Magick0ne/Other/Login_Items.jpg
    Every Startup - http://img.photobucket.com/albums/v326/Magick0ne/Other/Finder_Windows.jpg
    Message was edited by: Pifman

    Pifman wrote:
    Thanks to both of you. I guess the search I ran wasn't good enough as I didn't find the discussion that you posted.
    One of the possible workarounds posted there was to use a third-party program that I found difficult to understand and use. Instead I took V.K.'s advice and made an AppleScript and then made that script launch at login. Works like a charm.
    Only difference is that my AppleScript isn't located in the Utilities folder (10.5.8), instead I got to it by going to Applications / AppleScript / Script Editor.
    sorry, my mistake on the location.
    Then I made a script and saved it as an application. I then put that application in my Login Items (System Prefs / Accounts / Login Items).
    If you're having trouble finding the mount volume (or server) address, here's how you can find it: If you are currently connected to the volume(s) that you want to use, left-click it and hit Cmd+I (or right-click, Get Info). Use the address next to "Server:" - That's it!
    Hopefully Apple will fix this bug soon so people don't have to make AppleScripts just to make the OS work correctly.
    I wouldn't bet on it for leopard. leopard development has stopped now after snow leopard has been released. historically, Apple only releases security patches for old OS versions once a new one comes out. Interestingly, this bug is present in snow leopard too! or maybe they don't consider it a bug and this is how it should work. one can make a case for this, I guess.

  • Script for adding a login item for all accounts in the system

    Hi,
    Thanks for reading this query. I am new to the mac environment. I have developed a java application and created an installer of this application for MAC system.I want to run this application on starting the system. So I have written an apple script for adding this application in login items and this script will run immediately after completing installation process. And the entire process is fine. But the problem is, the application is added to login items of only the user who installed the application. But I want to get available the application in the login list of all accounts created in the system. How can I achieve this? Once more thanks in advance. I am attaching my script below:
    +*tell application "System Events"*+
    +* make login item at end with properties {path:"/Applications/MyApplication.app", hidden:true}*+
    +*end tell*+

    Hi,
    Try to use tables RSOSFIELDMAP, RSDSSEGFD and RSTRAN
    Hope it helps
    bhaskar

  • When i start my mac all kinds of programs automatically open up but under my login items is nothing

    When i start my macbook pro  alot of startup programs appear on my home screen even though under my system preferences in login items there is nothing selected

    Welcome to the Apple Support Communities
    If you have OS X Mountain Lion or Lion and you turn off your computer with those applications opened, Mac OS X will open them the next time you start Mac OS X. To avoid this, open  > Shut Down and unmark Restore windows when logging back in

  • Login Items connect to server in 10.5.6

    When you select a server volume in System Preferences / Accounts / Login items / to open a directory on a network server every time you log in, in system 10.5.5 and earlier the directory will be automatically opened on your desktop after startup.
    Not any more in system 10.5.6. The connection is made but the map will not be automatically openened any more (even when "hide" is not selected).

    Sounds like a tip that you should post to the server forums. Unless I missed something, there doesn't appear to be a question in your post.

  • By user login items to run UNIX executable file

    Hi all,
    Here is a plobem, I couldn't deal with for some days, please help me and give some advises .
    I want run a shell script when special user login the system, not all users.
    as I know and by test, the below methods are do the same work.
    1. System Preferences > Accounts > Login Items, add application and can run when user login.
    2. Two files: ~/Library/Preferences/com.apple.loginitems.plist or loginwindow.plist, and add useful items  to any of them.
    Because shell script can only open, but not run by "Login Items",  so at first I write a UNIX executable file , which is run the SH, and  gone into the System Preferences > Accounts > Login Items, add the UNIX file below, and set "Hide".
    When the user login the system again, it can auto open the terminal window, and run the UNIX exe file, but when the file end of exe, the terminal still open,
    and can't close. Here I have write command "exit" in the SH file, and the terminal show "the process has ended".
    I want the UNIX exe file  had better run in the backstage, if by terminal , how can make terminal hide?  or by what command can close the terminal ? 
    If it is not a good method,  whether there have any other way to  run the Shell Script flie in the backstage when certain  user login ?
    Here my Mac OS X workstation system is 10.5.8.
    please help me ,thank you .

    OK. My previous answer still holds. You don't need Terminal to run ssh, or AppleScript either, for that matter. What you do need is a process on the remote machine that will accept remote requests to run some appliction. It just so happens that sshd is such a program. I'm not sure about AppleScript. You may need to be logged on so that the Finder is running. I'm no AppleScript expert, so don't quote me. Again, I would just use ssh.

  • How do I stop Pages from opening when I log back in? Login items are not ticked.

    Prior to Yosemite I had trouble with Pages where it closed down the app when I closed a document.
    I was given a command line to put in the 'Terminal' to deactivate Pages. This worked.
    That command was -  -g NSDisableAutomaticTermination -bool TRUE/False.   But that isn't recognised any longer when I reverse the True/False.
    But I now don't want Pages to open automatically when I Log in.
    The box is not ticked for Pages in System Preferences- Users- Login Items.

    It needs to be removed from the list, not just unticked.
    (124669)

  • Login item - in a specific Space/Desktop

    I would like to have all the applications which are started up when I log on (System Preferences > Accounts > Login Items) started in a specific Space (desktop). Is this possible?

    Yep.
    In Login Items you have the option to show/hide login items, make sure all the ones you want to show are set appropriately there.
    Then in System Preferences go into Expose & Spaces, then the Spaces tab. You can set Application Assignments so apps start up in certain spaces or in every space.

  • Items in login items still load although unchecked

    I have a few items in System Preferences/Accounts/Login Items. Even though I have them unchecked they still load on rebooting. How do I stop that from happening?
    OSX 10.4.9

    Hi,
    The hint beneath my list of Login Items reads
    To hide an application when you log in, click its Hide checkbox
    Hiding is not the same as disabling.
    To disable a login item you have to delete it from this list:
    - Select it
    - Click the minus symbol beneath the list.
    ((Notice that some of this da**ed login items are started by a different mechanism. I.E. Version Cue from Adobe is started with a login hook - read: a text entry in the file /Library/Preferences/loginwindow.plist To get rid of such a thing you would have to delete or edit loginwindow.plist - but that is not for the faint of the heart))
    Cheers,
    Walter

  • "Airport basestation agent" item in login items: what to do ?

    hi,
    i habe both an airport extreme and airport express (extended network). in some of my macs a file "Airport basestation agent" is visible in system prefs/accounts/login items and in a brand new one not.
    1) what does this "Airport basestation agent" item do ?
    2) can i delete this "Airport basestation agent" item without harming my systems ?
    tia mike

    1) what does this "Airport basestation agent" item do ?
    Basically, the AirPort Base Station Agent monitors the "health" of the AirPort or Time Capsule and runs as a service. By default, it is started at user logon.
    2) can i delete this "Airport basestation agent" item without harming my systems ?
    Yes.

  • Can Login Items be disabled instead of just hidden/removed?

    cderalow wrote in another thread:
    "system preferences
    accounts
    login items
    uncheck as applicable "
    I always thought unchecking just made the app hidden on login but still launched. Is there a way of disabling items in this window instead of deleting them?
    Thanks.
    :-Joe

    Oh, I see. Hmmm, unfortunately, I can't think of an easy way to do that, off hand.
    The "login items" in the "Accounts" pref pane are recorded in the user's "~/Library/Preferences/loginwindow.plist" file. Conceptually, you could do what you are asking by backing up the original file, removing all login items, then editing the real file manually by copying back individual items from the backup. I suppose this might be slightly easier than having to open "System Preferences", then navigating to each individual item to be added back after each log in test -- but not by much.
    For example, suppose you open "/Applications" > "Utilities" > "Terminal.app" and run this command:<pre>plutil -convert xml1 ~/Library/Preferences/loginwindow.plist -o ~/Desktop/loginwindowBackup.plist</pre>A plain text XML version of the file should be created on your "Desktop" (the command assumes that a file named "loginwindowBackup.plist" did not already exist there - if it did, it would have been overwritten so be careful). It should be possible to open that file in a text editor, such as eg. "TextEdit.app".
    The "login items" are specified in the 'AutoLaunchedApplicationDictionary', which is bounded by the '<array></array>' tags. Within this array, each individual "login item" is specified within a "dictionary" entry (bounded by '<dict></dict>' tags), containing keys such as 'AliasData', 'Path', etc. Anyway, that whole dictionary entry (including the opening and closing 'dict' tags represents the "login item".
    So it should be possible to copy and paste one or more entries from the backup into a second copy of the "loginwindow.plist" file. After editing, that file (renamed "loginwindow.plist") could be copied back into "~/Library/Preferences", prior to logging out and back in to test the login item.
    It's probably easier than I have made it sound - easier on a technical level, at least, but still tedious to execute in practice...

  • Cant Stop Classic Startup at Login

    This has been addressed in the forum a couple of times but none of the solutions work.
    This is a single user system and so far I've tried:
    System Prefs/Classic login uncheck (and watched the com.apple.classic.plist change in the User/Library/Prefs/ByHost folder)
    I've trashed those prefs together with com.apple.loginwindow.plist and com.apple.systempreferences.plist from the user folder and re-created them by logging out and back in
    There are no visible start-up items either in OSX or Classic that might be triggering it
    I've checked Permissions
    Anyone else suffering from this found a solution (short of trashing and re-installing everything)?
    2GHz Dual G5   Mac OS X (10.4.6)  
    2GHz Dual G5   Mac OS X (10.4.6)  

    Hi Peter
    I don't use classic, so I'm not well read about this, but in System Preferences-Accounts-Login Items..... are there any entries there that might cause this?
    what about the StartupItems folders ? anything in those?
    There's one in /Library/ & one in /private/var/run/ ( you'll need to use Finder-Go-Go to folder... to get to this one )

  • Login Item keeps returning

    Hi There.
    I have read may similar posts, but the solutions have not worked.
    Problem: NetNewsWire returns to the "Login Items" all by itself, even after manually removing it from the Accounts -> Login Items.
    Things I have already tried:
    1) Manually removing it from System Preferences > Accounts > Login Items. Outcome: It removes from the list, but after loging out/in or restarting, it returns to the list.
    2) Deleting ~/library/Preferences/com.apple.loginitems.plist and ~/Library/Preferences/loginwindow.plist
    Outcome: The Login Item list in the System Preferences > Accounts is emptied, but after log out/in the list reappears, restoring NetNewsWire as well as several other things.
    3) Right-Clicking the Dock icon and de-delecting "Open at Login" which is always checked.
    Outcome: After un-checing this, and logging out/in. The app still launches and the setting in again checked in the dock menu.
    Any ideas would be greatly appreciated.
    Oh, by the way, this is on a family member's MacBook, 10.5.x
    Message was edited by: Andrew Mcvinnie

    Actually, I did further tests and found the following: there are several apps set to launch at start up, and removing any of them had the same effect as NetNewsWire.
    Here's how I solved the problem: after deleting all of the login items and verifying that System Preferences > Users > Login Items was empty, I went to ~/library/preferences and deleted loginwindow.plist. Then I used text edit to make a new blank file of the same name. I locked this file and put it in the preferences folder where it should go. I then tested to make sure that any login items added did not actually stick due to the fact the pref was locked. This worked, and nothing could be added or removed at all. I logged out and in and confirmed it again. My locked dummy file was still in place. Next, I removed the locked dummy file and went back to the login items and added a couple of items as a test. I logged out and in and just those two things opened. I removed them and verified that they also stayed deleted.
    Now the loginwindow.plist seems to be working normally. Something seems to have been restoring the file after I made changes, or perhaps the file was corrupt and unwriteable to begin with.
    Message was edited by: Andrew Mcvinnie

  • Deleted Login Items do not stay deleted. (OS X 10.6.8)

    I go to System Preferences > Accounts > Login Items and click the lock, then select unwanted applications and click "-" and re-lock the padlock, but next time I start the computer they are back. How can I remove them?

    List the items. You might find them throughout the computer in various Library folders in LaunchAgents, LaunchDaemons, or StartupItems.

Maybe you are looking for