"killall Finder" not working properly in Automator application

This is my Automator application:


User uploaded file

It runs to the point of killing the Finder (i.e. the icons disappear from my Desktop), but the Finder does not restart until I click on the Finder icon in my dock. I see the Automator Launcher appear in atMonitor and then disappear, so it appears that the script finishes running without the Finder restarting.


I tried adding a pause and moving "killall Finder" to a separate Run Shell Script action after the pause, to no avail.


How can I change the script, or the workflow, to force the Finder to restart after it is killed, without requiring a separate mouse click on the Finder icon in the Dock?

Posted on Apr 1, 2013 9:56 PM

Reply
4 replies

Apr 1, 2013 10:03 PM in response to louiexiv

Open the Script Editor or AppleScript Editor in one of the subfolders of Applications and use the following:


tell application "Finder" to quit

if (do shell script "defaults read com.apple.finder AppleShowAllFiles") is "1" then

do shell script "defaults write com.apple.finder AppleShowAllFiles 0"

else

do shell script "defaults write com.apple.finder AppleShowAllFiles 1"

end if

delay 2

tell application "Finder" to run


If you want to modify the shell script to do this, add:


osascript -e 'tell application "Finder" to run'


The killall command is working properly. It doesn't restart the process afterwards.


(79960)

Apr 1, 2013 10:31 PM in response to Niel

Alas, those suggestions do not work. The script generates the following in the console:


User uploaded file


With the osascript command, I see the following in the console:


User uploaded file


In both cases, I need to click on the Finder icon in the Dock for icons to reappear on my Desktop.


BTW, with both suggestions I see the Finder Dock light go off and back on; I just don't get any icons on the Desktop until I click on the Finder icon in the Dock.

Apr 2, 2013 12:11 AM in response to louiexiv

I solved this one after poking around and trying all suggestions and all ideas that came into my head as I read about "similar" problems. The solution appears to have two steps, although the second may be more a limitation on the first than an independent step.


As a preliminary matter, it is unnecessary to have anything more than "killall Finder" at the end of the shell script to have the Finder close and relaunch. I got the script working with nothing more than that at the end.


1. The Automator application belongs in the following directory:

~/Library/Scripts/Applications/Finder

I could not get it working until I moved it there, and it started working as soon as I moved it there. When I put the application in that directory, I saw a new entry for "Toggle Hidden Files" (my name) in the scripts pull-down menu in the Menu Bar. But see (2) below.


2. This one is strange and may be my own idiosyncracy because I keep a lot of my Automator stuff in an Applications subfolder and place aliases thereof in other folders. When I tried to drag the original Toggle Hidden Files application to the folder in (1), the Finder would only allow an alias to be placed in that folder. Fine, that's what I normally do anyway. However, any time I edit or even so much as open the application in Automator, the application disappears from the scripts pull-down menu in the Menu Bar and I must again drag the application (and thereby make an alias) to the folder in (1). There must be something special about that folder in Mountain Lion. Other folks may not see the same behavior with alias creation, editing the original application, or merely opening without editing the original application in Automator, but that's how it works on my iMac.


Maddening stuff.


P.S. One little oddity is that I can see Toggle Hidden Files in the scripts pull-down menu only when the focus is on my Desktop or an open Folder (or, presumably, some other aspect of the Finder). I'll just have to remember that. I can strain my brain only so much.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

"killall Finder" not working properly in Automator application

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.