Steve Gallant

Q: Using Automator to quit Finder

Hello,

I recently became a user of Pathfinder and it quite effectively replaces the functionality (and then some) of Finder. So I've been trying to build an Automator script to automatically quit Finder at login.

I have successfully done this, sort of.

I have created a workflow (listed at the bottom of this thread) that I saved as an app and set up as a login item on my profile. I also have it saved as a workflow. It's built to quit finder, then remove it from the dock.

Here's the strange part:

1) when I run the app manually (or automatically as a login item), it kills Finder but won't remove it from the dock
2) when I run the workflow manually, it kills Finder and removes it from the dock
3) when I set up the workflow as a login item, Automator just opens and the process doesn't run

Admittedly, I pieced together the workflow by finding various components in different forums, so it is far from original work

Also, is it possible to have Automator run in the background when this script runs?

Here's the workflow (2 elements); any suggestions are appreciated:


***

Run Shell Script (this kills Finder)

cat
osascript -e 'tell application "Finder" to quit'


Run AppleScript (this removes Finder from dock)

on run {input, parameters}
tell application "System Events" to tell process "Dock"
tell UI element "Finder" of list 1
perform action "AXShowMenu"
click menu item "Remove from Dock" of menu 1
end tell
end tell
return input
end run

***

iMac 20" Intel Core 2 Duo 2.4GHz, Mac OS X (10.5.8), 2GB RAM

Posted on Mar 10, 2010 12:33 AM

Close

Q: Using Automator to quit Finder

  • All replies
  • Helpful answers

  • by red_menace,

    red_menace red_menace Mar 10, 2010 6:40 PM in response to Steve Gallant
    Level 6 (15,551 points)
    Desktops
    Mar 10, 2010 6:40 PM in response to Steve Gallant
    You might try putting in a short delay after telling the Finder to quit. Not quite sure what the cat command is doing in there either.

    Automator doesn't run in the background, but for something like this you don't really need it at all - instead of using Automator to run shell scripts that run AppleScript, you can just put the whole thing into a single AppleScript.
  • by Király,

    Király Király Mar 11, 2010 9:29 AM in response to Steve Gallant
    Level 6 (9,848 points)
    Mac OS X
    Mar 11, 2010 9:29 AM in response to Steve Gallant
    Steve Gallant wrote:
    Hello,

    I recently became a user of Pathfinder and it quite effectively replaces the functionality (and then some) of Finder. So I've been trying to build an Automator script to automatically quit Finder at login.


    Doesn't Path Finder automatically quit Finder for you when you launch it? Path Finder does do this for me. Instead of trying to do this with Automator, you could just make Path Finder a login item, and then Finder will be closed for you upon login.
  • by Steve Gallant,

    Steve Gallant Steve Gallant Mar 11, 2010 10:03 AM in response to red_menace
    Level 1 (1 points)
    Mar 11, 2010 10:03 AM in response to red_menace
    Thanks, I'll give this a shot.

    And, being only partially familiar with programming languages myself, I was curious about the cat command but didn't want to toy with it when it was working.

    Anyhow, I'll give it a try and update the thread.
  • by Steve Gallant,

    Steve Gallant Steve Gallant Mar 13, 2010 5:26 PM in response to Steve Gallant
    Level 1 (1 points)
    Mar 13, 2010 5:26 PM in response to Steve Gallant
    Got it working.

    Here's what I used:

    tell application "Finder" to quit
    tell application "System Events" to tell process "Dock"
    tell UI element "Finder" of list 1
    perform action "AXShowMenu"
    click menu item "Remove from Dock" of menu 1
    end tell
    end tell
    end run

    Saved it as a bundled app and presto!

    Thanks for the suggestion.
  • by Osiyo,

    Osiyo Osiyo Oct 5, 2016 10:10 PM in response to Steve Gallant
    Level 1 (13 points)
    Desktops
    Oct 5, 2016 10:10 PM in response to Steve Gallant

    Yes, Me too, Steve. But I ran into an odder issue.

     

    Opened that issue in reply to Leviepex's informative 'A method to quit all apps at once'. Linking here, from there. And then returning here, to try and make more sense of an apparent bug demonstrated by Apple and by off-world apps.

     

    The issue is behavior demonstrating Finder security, and the manner in which AppleScripts 'Quit All Applications' removes Finder stability. Pathfinder app also elicits the same system instability. The alarming behavior is vanishing Dock and Menu Bar. Sometimes, after quit all with an Apple app open (Text Edit) and an item in Trash (a web page, say)  Menu Bar remains hidden until Finder icon is clicked. Of course, where Pathfinder removes Finder presence, a system crash occurs, meaning manual ⎋ reboot, rather than just the Apple app closed followed by clicking Finder. Pathfinder and AppleScript 'Quit All Applications' seem to be activating the same or similar bug here.

     

    A solution appears to lie in engaging Trash and adding your osascript manipulation, as follows.

     

    • Utilities > Quit All Applications
    • Utilities > Run AppleScript
      tell application "Finder"
      empty the trash
      end tell
    • Utilities > Run AppleScript
      cat
      osascript -e 'tell application "Finder" to quit'
    • Save Automator Application as something or other... yes?

    When this solution is applied, the erratic and inconsistent disappearance of Dock and Menu Bar ends.

    Not sure what that means, except that I got lucky, maybe. DOS 4.2 got kinky like this in parent-child batch runtimes back in the 80's. Let's hope Apple covers that hole. Quick! Or whenever...

     

    Using Automator to quit Finder
    A method to quit all apps at once
    Emptying the trash automatically
    Using Automator to quit Finder

  • by Osiyo,

    Osiyo Osiyo Oct 7, 2016 1:53 AM in response to Osiyo
    Level 1 (13 points)
    Desktops
    Oct 7, 2016 1:53 AM in response to Osiyo

    Except that Finder Inspector fails to close, and may cause an error popup under two conditions that I have identified on a Mac with a 2016 logic board that blocks DIMM slot 1! Thus, Inspector issue may indicate a 'marginal' machine capability, or a more interesting Automator development issue, if you and others on healthy machines run into the same Inspector reluctance to close.

    1. Where Safari is open and Finder is viewing a folder, only Safari closes - Inspector and Finder folder view remain open.
    2. Where any other app than Safari is open, and a Finder folder view is open, beside any other open app than Safari, there is an error popup 'Finder was unable to compete the close action', and Finder Inspector is still open.
    3. Where any other app than Safari is open, if Finder Inspector is the only Finder Window active, there is an error popup 'Finder was unable to compete the close action', and Finder Inspector is still open.