login item

hi
is it possible to add login item with applescript
if so please let me know.
thanks

This may require System Events 1.2:

tell application "System Events" to make login item at end with properties {path:(POSIX path of "path:to:application"), hidden:false}

Jon

thanks
jonn8
but for some reason it given me error
Can’t get POSIX path of “Macintosh HD:Users:Shared:yahoo:yahoo Projector”.
have any idea

Try:

This should work and return the proper path to the application. It may be that the application has a hidden extension like “.app”.

Good luck,
Jon

Thanks
john88
It works but I have thousands of scripts as application and it takes long time to read those file and then select the file for log in item.

You have thousands of script apps to add?!?! Still, you can create a repeat loop that searches through a folder looking for script apps and then adds them. Something like:

Once you have tested this (initially when run, it will try to get all the script apps in a folder and its subfolders but it will only return the apps as aliases, it won’t actually add them), you can take out the commented line indicated in the script to actually add the apps to your login items. Again, this isn’t as fast as some other routines for getting subfolders since it uses the Finder but it should give you a place to start.

Good luck,
Jon

hi
John
It seems to be lot of work for you
But I think you misunderstood me
Sorry for not explaining properly

here is what I want to do
I have a projector file named “Main Projector” in the shared folder on the MAc
there is a user call “tom” who is just access to simple finder and I want to set up the log in item for him and that is “Main Projector”
I can easily set it up once in system prefrences and it works well
But some times for some reason"tom" loose the the content of login item.
So i want to put a script in the Shared folder that “tom” can click it to run and it automatially set the “Main Projector” as login item.

Um, what? Where did the “thousands of scripts” comment come from? If there is just one file, just hardcode the path using the first script. The second script was just to illustrate that you probably were using the wrong full path to the item you wanted to add to the login items.

Jon

Hi
john
thanks for all your concern in my issue
I like your first script but for some reason it always give me error of wrong path.
here is the script with path I tried

tell application "System Events" to make login item at end with properties {path:(POSIX path of "Macintosh HD:Users:Shared:yahoo:yahoo Projector"), hidden:false}

According to me the path is right but it gives me error
Can’t get POSIX path of “Macintosh HD:Users:Shared:yahoo:yahoo Projector”.

Now the second script
when i run that script it freeze the applescript application and after a long time it tell me to choose the application. The list of applications was very long because it show all the applictions on my computer plus all the applescript which were saved as application and they are thousands in number.
So it is hard for anybody to choose the application from such a long list of applications.
hope you got it and sorry for not being clear with my issue
thanks

Hi john
i worked on the secons script you gave me and tell me to choose the application and when i choose it and clik o.k. and then it give me error

Can't get POSIX path of "yahoo Projector".

have any idea
thanks once again

Sorry, it should have been:

Once you have the path, change the script to the hard coded path and not the “choose file…” line.

Jon

hi
john
its still giving me the same error
Can’t get POSIX path of “Macintosh HD:Applications:Safari.app:”.
this error was given after I select the “Safari” application from “choose file” window
please give some suggestions

I don’t know what to tell you, this works fine on my machine (10.2.6/AS 1.9.1):

Jon

frustrated
john
the test you send me is fine
but script doesn’t work
it give me same error on different machine.
I tried on two different imacs and one g4 running os10.2.6 with selections of different applications, but same error .
the error comes with selection of this line in the script

make login item at end with properties {path:(POSIX path of the_app), hidden:false}

hope you or somebody else have some suggestions

If the test works, lets try moving the coercion to POSIX path out of the tell block:

So, the hardcoded version would be:

Jon

thats great john
Atlast you didi it for me i can’t believe it
thankyou very much
you did great hard job for me

thanks once agian

hi
john works hard to solve my problem to set up the log in item.
this the script that he gave me and works well for me but I want to add some more thing in to the script.

here is the script that works for me


set the_app to "/Applications/Safari.app/" 
tell application "System Events" to make login item at end with properties {path:the_app, hidden:false}

here is what i want to add
1- remove all other items from log in window
2 - when the other user tries to run the script it ask for administrative password. I want to remove that, i mean to avoid that prompt and the other user can set up the login item.

please reply
thanks