• 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
Re: Add to startup items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add to startup items


  • Subject: Re: Add to startup items
  • From: Bill White <email@hidden>
  • Date: Thu, 20 May 2004 08:01:23 -0400

On 5/20/04 4:47 AM, Thomas C. <email@hidden> wrote:

> I'd like to know if this is possible from AS to add and remove applications to
> / from startup items of the logged account. I would also need a security to
> avoid adding an application that is already in the startup items

To remove items you could do something like this:

---------- BEGIN SCRIPT ----------

tell application "System Events"

set loginItems to name of every login item

set appName to item 1 of (choose from list loginItems with prompt
"Remove what?")

delete (every login item whose name is appName)

end tell

----------- END SCRIPT -----------

To add items, I use the following droplet:

---------- BEGIN SCRIPT ----------

on run

set theApp to choose file of type {"APPL"}
my addtologin(theApp)

end run

on open theFiles

repeat with theApp in theFiles

tell application "Finder"

if kind of theApp is not folder then my addtologin(theApp)

end tell

end repeat

end open

on trimName(thisApp) -- gets rid of .app extension

set AppleScript's text item delimiters to ".app"

set trimmedAppName to text item 1 of thisApp

set AppleScript's text item delimiters to ""

return trimmedAppName

end trimName

on addtologin(thisApp) -- adds an item to login items

set appPath to POSIX path of thisApp

tell application "System Events"

set appName to name of thisApp
set shortName to my trimName(appName)

if shortName is not in (name of every login item) then
make login item at end with properties {path:appPath}
end if

end tell

end addtologin

----------- END SCRIPT -----------

Hope that helps,

Bill
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Saving HTML from Entourage
      • From: Mr Tea <email@hidden>
    • Re: Add to startup items
      • From: "Thomas C." <email@hidden>
References: 
 >Add to startup items (From: "Thomas C." <email@hidden>)

  • Prev by Date: Re: new venerability on macosxhints through Safari
  • Next by Date: Re: Print to PDF
  • Previous by thread: Add to startup items
  • Next by thread: Re: Add to startup items
  • Index(es):
    • Date
    • Thread