View Full Version : quit all login items throws err
himanshu
11-16-2010, 05:28 AM
--run below script get err
--attach snapshot, what to add for smooth logout all apps one by one
tell application "System Events" to set the visible of every process to true
tell application "System Events" to set the visible of every process to true
set _list to {"Finder"}
try
tell application "Finder"
set p_list to the name of every process whose visible is true
end tell
repeat with i from 1 to (number of items in p_list)
set this_process to item i of the p_list
if this_process is not in _list then
tell application this_process
quit
end tell
end if
end repeat
on error
tell the current application to display dialog "An error has occurred!" & return & "This script will now quit" buttons {"Quit"} default button 1 with icon 0
end try
renaultssoftware
11-16-2010, 06:43 AM
It's not clear what you're trying to do here. Just giving us the script is like giving us eggs, flour, food colouring and such; we're looking for the recipe. What do you want this for?
himanshu
11-16-2010, 07:31 AM
my objective to "Log out applications one by one only" from Dock
I think my script is not professional is missing some syntax
writing same code by adding some syntax change given by professional coder like u make my life easier
If I write complete wrong script u can give some direction
DeltaMac
11-16-2010, 08:26 AM
It seems that your script is simply trying to go through the running processes, and quitting them one at a time. The problem comes when your script tries to quit a process that is being used by another app while _that_ app is still running.
Wouldn't it be better to quit the app, and not the internal processes that app may be using at the time? Seems like that would be the method that you should use.
What is the reason that you need to "Log out applications one by one only" from Dock?
If you can tell us why you need to that, then someone may have an idea that will give you a smoother flow to a logout...
himanshu
11-16-2010, 08:42 AM
i need to log out one by one
empty cache and trash
from Library..now pls help...!!
tlarkin
11-16-2010, 08:59 AM
What is your higher goal here though? We still need to know more information, like what exactly are you trying to accomplish. Using an AppleScript to quit all processes is not really ideal, for anything I would think.
renaultssoftware
11-16-2010, 03:24 PM
What is your higher goal here though? We still need to know more information, like what exactly are you trying to accomplish. Using an AppleScript to quit all processes is not really ideal, for anything I would think.
Yep. Just saying "I need help" over and over again will get you nowhere. Please say why you want this.
DeltaMac
11-16-2010, 03:37 PM
Yes - If you can provide some details about why you want to do this, someone may suggest a better solution.
renaultssoftware
11-16-2010, 04:24 PM
OK, I get it, I think. When you're running this script, it tries to quit AppleScript Editor, which is running the script. Much like sawing off a tree branch you're sitting on (http://www.youtube.com/watch?v=4tyvhq7uhTM).
Red_Menace
11-16-2010, 06:12 PM
Much like sawing off a tree branch you're sitting on.
That's too funny - I didn't think there was anyone left to do stuff like that.
There are many processes running in the background that you probably shouldn't quit (loginwindow, SystemUIServer, Dock, etc), so I am guessing that you are wanting to quit just the applications you are running. Here is a script I use - I run it from the Script Menu, but it adds its name to the exclusion list so that it doesn't try to quit itself if running as an application.
-- add or remove applications from the following list to exclude from quitting:
property excludedApps : {"Finder", "Safari"}
-- add the name of this script, just in case running as an application
tell application "System Events" to tell disk item (get (path to me) as text)
set {theName, theExtension} to {name, name extension}
end tell
if theExtension is in {missing value, ""} then
set theExtension to ""
else
set theExtension to "." & theExtension
end if
set theName to text 1 thru -((count theExtension) + 1) of theName -- the name part
set the end of excludedApps to theName -- add me to the excluded list
-- if running from the Script Menu, the AppeScript Runner will be in the background
set theEditedList to {}
tell application "System Events" to get the name of every process whose background only is not true
repeat with TheProcess in the result -- edit out excluded items
if TheProcess is not in excludedApps then set theEditedList to theEditedList & TheProcess
end repeat
if theEditedList is {} then return -- no apps to quit
set theQuitList to choose from list theEditedList with prompt ¬
"Select the application(s) to quit:" default items {} OK button name "Quit Selection" cancel button name ¬
"Quit All" with multiple selections allowed and empty selection allowed
if theQuitList is {} then return -- no selection
if theQuitList is false then -- "cancel" button
set alertText to "Quiting all applications:"
else
set alertText to "Quiting applications:"
set theEditedList to theQuitList
end if
-- throw up an alert with the applications to quit
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return & tab}
set quitText to tab & theEditedList as text
set AppleScript's text item delimiters to TempTID
display alert alertText message quitText as warning buttons {"Cancel", "OK"} cancel button "Cancel" giving up after 5
repeat with appName in theEditedList -- quit
try
tell application "System Events" to get bundle identifier of application process appName
tell application id result to quit
-- do shell script "killall -u $(id -un) -c " & quoted form of appName
on error errmess
log errmess
end try
end repeat
himanshu
11-17-2010, 12:24 AM
I want to quit all running applications...reason is there is all unnecessary files in cache, log folder that I want to delete them as applications quitting one by one I can extend script further to empty those folders...I do not think this is illegal..now onwards I will not write word "pls help"....
renaultssoftware
11-17-2010, 06:52 AM
reason is there is all unnecessary files in cache, log folder that I want to delete them as applications quitting one by one I can extend script further to empty those folders
What do you mean 'cache', temporary files or ~/Library/Preferences? You don't want to delete anything in the latter case (they're small files), and in the temp-file case it gets emptied at shutdown.
Why not just log out and/or shutdown, it'll bring you to the same goal, I guess.
Are you running out of disk space, is that the issue?
himanshu
11-17-2010, 07:34 AM
sorry..Red Menace script is not working...and for renault....I want to delete cache for font book reinstallation purpose.....I want to delete font book app and reinstall all fonts from path into it...there is flucation of font reserve client and font book...so need to write script
tlarkin
11-17-2010, 08:41 AM
how are you reinstalling it? Normally, you do not need to delete before you reinstall something, with a few exceptions.
Can you give more detail about what you are trying to accomplish?
himanshu
11-17-2010, 09:08 AM
how are you reinstalling it? Normally, you do not need to delete before you reinstall something, with a few exceptions.
Can you give more detail about what you are trying to accomplish?
i will delete it from applications and reinstall from ftp path
this is dead end i do not have further words for explanation
tlarkin
11-17-2010, 09:50 AM
It just doesn't make sense to do it the way you are executing this method. What apps are they exactly? Do they have installers? Installers can just be dropped over ARD admin and be done.
I can probably give you the top 5 best practices to do this if I was given more information on what exactly you are doing.
Red_Menace
11-17-2010, 07:53 PM
My previously posted script has a problem with the bundle ID part when running in Tiger, so just change
tell application "System Events" to get bundle identifier of application process appName
tell application id result to quit
to
tell application appName to quit
himanshu
11-18-2010, 03:02 AM
It just doesn't make sense to do it the way you are executing this method. What apps are they exactly? Do they have installers? Installers can just be dropped over ARD admin and be done.
I can probably give you the top 5 best practices to do this if I was given more information on what exactly you are doing.
thunderbird,skype,terminal,script editor,firefox,safari,dashboard,open office
I can not understand installers, I want to quit above applications one by one
then I will delete font book app and I have installer of that on other FTP
I will reinstall font book from there
himanshu
11-18-2010, 03:11 AM
OK, I get it, I think. When you're running this script, it tries to quit AppleScript Editor, which is running the script. Much like sawing off a tree branch you're sitting on (http://www.youtube.com/watch?v=4tyvhq7uhTM).
yes u r right, but script work properly as is where is , smoothly after my death
himanshu
11-18-2010, 03:15 AM
My previously posted script has a problem with the bundle ID part when running in Tiger, so just change
tell application "System Events" to get bundle identifier of application process appName
tell application id result to quit
to
tell application appName to quit
I want to quit all running applications
I need a script like below systex
tell application "Finder" to quit all running applications
renaultssoftware
11-18-2010, 06:17 AM
Why do you want to quit all running applications? Some, like Dock, restart invariably.
What are you trying to do by quitting all running applications?
himanshu
11-18-2010, 07:12 AM
Why do you want to quit all running applications? Some, like Dock, restart invariably.
What are you trying to do by quitting all running applications?
not say dock, all login items needs to be log out one by one then restart all items one by one so that save changes in web app were saved and app will reopen and cache and logs will be cleared...this is it!!!
tlarkin
11-18-2010, 08:14 AM
Do uses log in/out of these computers? Why not just do a log out hook that does all of this so when they log out it clears all cache and other items? That way all the apps will be quit and if users have issues just tell them to reboot, which also involves a log out.
himanshu
11-18-2010, 08:30 AM
i can not understand "hook" i want to quit running apps one by one but do not want to restart mac, pls give some example in one line of script...i can understand example very well
tlarkin
11-18-2010, 09:16 AM
If users are currently using apps and you start quitting them one by one you will run into several problems:
1) Some apps will prompt to be quit and the user can say no
2) Users will lose any unsaved data when the app is quit
3) Sometimes apps work together and when in "use" it will not quit
here is an article about logout hooks
http://hints.macworld.com/article.php?story=20090625155239817
Essentially, every time a user logs out, the script runs and clears cache and temp files. This would be considered best practice over writing a script that one by one kills that app then restarts it. You will run into too many issues that way.
Red_Menace
11-18-2010, 06:33 PM
I want to quit all running applications
I need a script like below systex
tell application "Finder" to quit all running applications
You don't need to use the Finder to quit an application, since the Finder doesn't have anything to do with it. The normal way to quit all of your applications (well, what I consider normal anyway) is to get a list of the current applications, filter for stuff you want to exclude, then go thru the list telling each application to quit.
This topic is starting to look familiar...
renaultssoftware
11-18-2010, 08:21 PM
This topic is starting to look familiar...
Why so? Is it something you've seen before?
tlarkin
11-21-2010, 12:25 PM
Furthermore, if a user renames a process to something different, it defeats your purpose.
Not that you need to wipe cache, temp files and such but if you really want to you most likely should do it as a logout hook.
himanshu
11-22-2010, 01:37 AM
I m unable to understand, why u people make this discussion so hot...
in win PC there is tool CCleaner...doing the same..I need to develope only one or twice functionality of that tool for mac..THE END.
kindly not that..do not suggest me paid tool or 30 day versions
renaultssoftware
11-22-2010, 07:14 AM
What is CCleaner; what does it do? If it's to wipe disc drives, simply use Disk Utility. If it's a defrag tool, you will have to buy software, I'm sorry to say.
I suppose that programming this is above your head.
renaultssoftware
11-22-2010, 07:41 AM
I ask you again what CCleaner does?
tlarkin
11-22-2010, 08:12 AM
CCCleaner is a freeware app for Windows that clears out all temp files and cache files for Windows and third party apps that put cache files in certain user folders in Windows.
Like I said earlier, this does not have to be done really on a Mac and if you wanted to do this, it should be done as a logout hook.
I still do not understand fully what you are trying to accomplish. By design OS X clears these temp and cache files on a regular basis, because it has superior logging settings/configurations compared to windows. The only time you need to clear such things is when they run out-of-whack and need to be cleared.
You really do not need to do this, and typically if things like this do happen a simple reboot clears them out.
renaultssoftware
11-22-2010, 03:28 PM
You really do not need to do this, and typically if things like this do happen a simple reboot clears them out.
Correct, rebooting automatically clears the cache.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.