Kill process with AS

Discussion in 'Mac Programming' started by noobsauce, May 29, 2010.

  1. noobsauce macrumors member

    Mar 23, 2010
    How do i kill a process (finder) using applescript and should i save it as a script, application or text?
  2. Caleb531 macrumors 6502


    Oct 17, 2009
    This is the easiest way to restart the Finder:

    do shell script "killall Finder"
    The you can save the it as an application, and run it whenever you want to restart the Finder. Note that using the killall command normally force quits applications, the Finder and Dock are the only applications which will restart automatically.
  3. larkost macrumors 6502a

    Oct 13, 2007
    In this case dropping out to a shell script command is probably not the best way of doing what you want. The "killall" command will yank the rug out from underneath the Finder, not allowing it to do things it would normally do when closing (like saving its preference files). Plus you are dropping out of AppleScript in order to do something that AppleScript is better able to do.

    The better, and simpler solution is this line in AppleScript:
    tell application "Finder" to quit
  4. noobsauce thread starter macrumors member

    Mar 23, 2010
    I wrote a script that opens hundreds of finder windows and i need it to quit immediately before the computer crashes.

Share This Page