Kill process with AS

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

  1. noobsauce macrumors member

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

    Caleb531

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

    Code:
    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

    Joined:
    Oct 13, 2007
    #3
    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:
    Code:
    tell application "Finder" to quit
     
  4. noobsauce thread starter macrumors member

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

Share This Page