Quitting an application and checking if it quit with a script.

I need to shut programmes several down with a script and than check if it happened. If the programme would throw up a dialogue box I want it to ‘click’ OK. Than check if it is quitted and if not try again, failing that (the programme hangs) force quit it.
Would this be possible?
I am a novice at scripting and have tried to no avail. Any suggestions?

red_menace wrote:
You can quit an application with the standard saving options of yes, no, or ask, for example:
tell application "TextEdit" to quit saving no
I am familiar with this one.
red_menace wrote:
You can also force quit an application with a shell script, for example:
do shell script "killall TextEdit"
Not ideal, but yes (killall can really screw things up in the end like force quit). but yes if hanging....
red_menace wrote:
I'm not sure if your particular sequence will work if you want to save any changes, though - if the application hangs while quitting, then the script will also hang, and the saving options of the quit allow the user to cancel, which will also cancel the script. The following script will quit the specified application, but if there is an error (such as the user canceling) then any changes will be lost:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFDDFF;
overflow: auto;"
title="this text can be pasted into the Script Editor">
tell application "System Events" to try
if exists process "TextEdit" then tell application "TextEdit" to quit saving yes
on error
do shell script "killall TextEdit"
end try
</pre>
Agreed and yes it works if I substitute the 'yes' for 'no'. for some reason Text Edit does not allow 'yes' or 'ask'. do you know why that could be?

Similar Messages

  • Game port already in use quit other application and try again?

    ok didnt know where to post it but, i got a mac mini and im up to date on all updates. I play warcraft three frozen throne computer game on it. I play a few matches or so in custom games then boom a message pops up saying that another application is using a needed gaming port, please quit other application and try again. I have no idea what it is talking about because the only thing im running is warcraft three. I have no clue how to fix this, so if anyone knows please help me out here.

    Thanks Mr. Goodwin - that was the high tech way of finding who is using port 8300.
    I did a low tech search - edited hyperion/logs/ configtool.log and found that a previous administrator configured Planning to use that port:
    +(May 05, 2008, 10:30:23 PM), com.hyperion.cis.config.wizard.Tomcat5DeploymentPanel, DEBUG, Checking for valid Tomcat serverName+
    +(May 05, 2008, 10:30:23 PM), com.hyperion.cis.config.wizard.AppServerDeploymentPanel, DEBUG, Deploy component [1]: Planning+
    +(May 05, 2008, 10:30:23 PM), com.hyperion.cis.config.wizard.AppServerDeploymentPanel, DEBUG, Server Name: HyperionPlanning+
    +(May 05, 2008, 10:30:23 PM), com.hyperion.cis.config.wizard.AppServerDeploymentPanel, DEBUG, Listen Port: 8300+
    +(May 05, 2008, 10:30:24 PM), com.hyperion.cis.config.wizard.Tomcat5DeploymentPanel, DEBUG, Checking for valid Tomcat serverName+
    Question now is this, since Planning has already been configure to use Tomcat at port 8300, why can't I configure it to use that port again? Anyways, I guess I should not select "Deploy to Application server" on the Config tool.
    Edited by: user643332 on Mar 25, 2009 12:42 PM

  • Applications and software update keep quitting unexpectedly

    Safari, iTunes and even software update are quitting exexpectedly? What do I do ?

    First, ensure you have a good external backup.  Get a copy of your data, on the off chance there's something wrong.
    Then boot from the Recovery Partition or boot from the DVD (depending on your release) and use Disk Utility to check your disk structures and check your permissions, as a start.
    You can also launch Applications > Utilities > Console.app and see if there are relevent error messages, though the messages there can be cryptic.
    Some information on the OS X version and the type of Mac could be useful in assisting you, as some of the sequences vary by OS X version.  If you're not sure, you can use  > About This Mac to get some details.

  • Why can't I open PDF files on my iMac. I installed Adobe Reader and accepted the end user license, as instructed then quit the application and relaunched it and I still can't view the PDF document. The screen comes out black. Please advice. Thanks

    Why can I view PDF files from the Web on my iMac even after I installed Adobe Reader and accepted the end user license agreement.I then quit the application relaunched it, as instructed snd still the PDF document comes out blank or black. Please advice. Thanks
    Chef Rey

    Are you saying that Adobe Reader or Preview can't read PDF file that you download? Or, are you saying that you can't display PDF files in your Safari broweer? If the latter, then delete any AdobePDFViewer plugins you find in /Library/Internet Plug-ins/ and restart. That should allow Safari to display PDFs in its window. BTW, that's the worst place to view them. Better to download them and use Adobe Reader or Preview.

  • Many times it happens that even I had closed the application window i had to manually  quit the application by going in 'forced quit'..any solution .. :(

     many times it happnes that even I had closed the application window  it keep running  on backend and I have to manualy close it again by going in  'forced quit'.. any solution.... 

    Closing the window doesn't quit the application on Mac like it does in Windows. You have to select Quit (Program Name) from the top menu or use the keyboard shortcut Command + Q

  • Must force quit to close and won't display links with pdf or quicktime

    when i try to close firefox it gets hung up and i must force quit. also when i try to open links like show a bill and it a pdf the screen goes blank. also other links that use quicktime fail as well. all this works fine in safari so i must conclude it is a fire fox issue.

    You do not have a problem with the iPhoto application - you have a problem with the iPhoto library
    Back up your iPhoto library, Depress and hold the option (alt) and command keys and launch iPhoto - rebuild your iPhoto library database
    LN

  • How do I restore original version of pages on my Macbook Pro?  I had it listed on my bottom applications and when I hit "quit" it disappeared altogether.

    How do I restore original version of Pages on my MacBook Pro?  I saw the application was still open, so I pushed QUIT and it disappeared and now can only find the new version of pages which no longer supports my templates.  Thank you.

    It's in Applications>iWork 09

  • I am facing this issues that music stops playing when the display goes...Please help me with this, I already reset and checked headphones still quits working.

    My IPod Nano stops playing music when display goes out.  I already tried the resolutions suggested and still having problem.  Please help!

    i've had my ipod for awhile and it just started doing this - last night.  it plays for about 30 seconds and stops.  i press play again and it restarts where it had stopped.  i had wondered if i had accidentally set it to 'sample' or something.

  • About 90% of the time, when I try to close a PDF nothing happens. After repeatedly clicking the X I get the following message. The Organizer Database is damaged and will be reset the next time Acrobat is launched. Quit the application and close any curren

    Anybody had this Problem?
    garym57236896

    You must be using an old version of Acrobat as Organizer hasn't been in the last two versions of Acrobat.  Here is the KB that covers that old error:  Error "The Organizer Database is damaged and will be reset..." | Acrobat 9

  • Combo box and Check box..help with code please?

    Here is my problem...i have a list of check boxes and according to which one is checked, i need combo boxes to populate different choices.
    as an easy example im only using 2 check boxes and two combo boxes.
    the check boxes are named Choice 1or2 with export values of 1 and 2
    the Combo Boxes are named List A and List B..
    both containing options that say you checked box 1 and you checked box 2
    any help would be greatly appreciated

    Implode wrote:
    "Help with code please."
    In the future, please use a meaningful subject. Given that you're posting here, it's kind of a given that you're looking for help with the code. The whole point of the subject is to give people a high level idea of what KIND of help with what KIND of code you need, so they can decide if they're interested and qualified to help.
    Exception in thread "main" java.lang.NumberFormatException: For input string: "fgg"
         at java.lang.NumberFormatException.forInputString(Unknown Source)
         at java.lang.Integer.parseInt(Unknown Source)
         at java.lang.Integer.parseInt(Unknown Source)
         at assignment1.Game.Start(Game.java:120)
         at assignment1.RunGame.main(RunGame.java:18)This error message is telling you exactly what's wrong. At line 120 of Game.java, in the Start method (which should start with lowercase "s" to follow conventions, by the way), you're calling Integer.parseInt, but "fgg" is not a valid int.

  • C5280 printer error "remove and check colour cartidge" even with new cartridge and contact cleaning

    Error message repeats even after-
    1 installing new colour cartridge,
    2 cleaning of cartrdge contacts, and printer contacts
    3  off/on power,
    4  sliding cartridge from right to left
    5 removed and placed back paper
    6 unplug electrical wire connection
    Thank you

    Try steps 3,4,5,6 in the link below:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c01611456&cc=us&lc=en&dlc=en&product=3204464&tmp...
    I work for HP but my posts and replies are my own.
    Have a great day!!!

  • Safari hangs and times out on pages with CGI scripts

    I don't know if this is a Safari problem or a system wide problem. I running OS 10.4.9 with Safari 2.0.4. When I try to load a page that begins with "http://cgi." it begins to load but hangs and eventually times out. Has anyone else run into this problem? I did a search of the forum but came back with no results.
    PowerBook G4   Mac OS X (10.4.9)  

    I don't know if this is a Safari problem or a system wide problem. I running OS 10.4.9 with Safari 2.0.4. When I try to load a page that begins with "http://cgi." it begins to load but hangs and eventually times out. Has anyone else run into this problem? I did a search of the forum but came back with no results.
    PowerBook G4   Mac OS X (10.4.9)  

  • Drag and Drop Image to PDF with Java Script

    Hi,
    I have to create some PDF reports and contained within these reports there are numerous images, some as many as 30-40. This is really time consuming. Can anyone please advise if there is some java script available so I may Drag & Drop an image onto a button or directly onto the PDF report.
    I have attached an example video of the current process and as you will see the process is very long to say the least. Any assistance would be appreciated.
    Kind Regards
    Terry Lewis

    Hi Gilad,
    Apologies for that I edited the wrong video in my Youtube account.
    You mentioned that its not possible with JS.
    Are you aware of any other options?
    Kind regards
    Terry
    P.S. I have amended the video situation.

  • AppleScript Application - Multiple buttons don't work with one script...

    Okay, so I need to control just about 22 buttons to make this project work. But. I still can't get 2 to work.
    Here is my script:
    on clicked theButton
      -- Preferences:
              if title of theButton = "Save" then
                             set Word1 to the contents of the text field "WordDefine1" of window "Preferences"
                        display dialog "Saved the words:" & return & "-" & Word1
      --  Process of word one:
              else if title of theButton = "Say1" then
                        display dialog "I hope I see this cuz then that button works. YAY!"
              else if title of theButton = "Check1" then
                        if Word1 = contents of text field "WordInput1" of window "iSpell" then
                                  say "If I can even see THIS, I am like in AppleScript heaven. BOTH buttons work!"
         end if
      end if
    end clicked
    So when I click the "Save" button, it displays the defined dialog. But the button "Say1" does absoulutely nothing. Same for the "Check1" button.
    I'm guessing I did something wrong here...
    Thanks in advance
    P.S. (I'm not actually using the actions see here for the last 2 buttons:)

    Okay, thanks so much, the buttonName script worked. This is part of what I have now:
    -- Preferences:
    if buttonName = "Save" then
      set Word1 to the contents of the text field "WordDefine1" of window "Preferences"
      display dialog "Saved the words:" & return & "-" & Word1
      --  Process of word one:
      else if buttonName = "Say1" then
      say Word1
    The diplay dialog line at the end of the "Save" button script works, but when I do the say button, it has an AppleScript Error, saying that the variable Word1 is not defined. But the display dialog thing works. What the heck.

  • Launchin an application and waiting until it has quit

    Hi,
    I'm trying to use automator to swap different users settings before launching an application. This much is straight forward. What I would like to do is to save the settings when the application is closed.
    But I can't work out how to launch the application and then have the workflow wait until it closes again before backing up the user settings. Is this possible just using automator or do I need to start using apple scripts?
    Thanks
    Nic

    Well, yes, you could have a workflow wait until an application closes. The workflow would loop forever checking to see if the app is running, and if isn't then backup the settings and stop looping. Hmm, you'd want to use some AppleScript for that. I used "TextEdit" as the application to test this, so you'd want to change that to the name of the app you are checking. It pauses for 5 seconds, but feel free to adjust that to whatever.
    repeat
    if application "TextEdit" is not running then exit repeat
    delay 5
    end repeat
    Add the action "Run AppleScript" (Utilities category, or Automator app) as the first action before your actions that backup the settings. Just delete everything in the "Run AppleScript" action and then add the above script. The default script in "Run AppleScript" is for passing stuff from a previous action to the next action, but since this is the first action you don't need the default script. (It shouldn't hurt to leave it, either, but you don't need it.)
    When the workflow is run, it'll stay stuck in the first action waiting for TextEdit (or your app) to quit. When it finally does, the workflow will move to the next actions you've provided for backing up the settings.
    Hmm. Thinking a bit...
    One alternative to this would be to create a workflow to quit the application, and then have it backup the settings. You would have to use the workflow instead of quitting the app normally, that is you couldn't quit from the menu nor use Cmd-Q. There's an action called "Quit Application" in Utilities category (or Finder action). Use that as your first action, then possibly the "Pause" action (Utilities category, Automator app) set to 5 or 10 seconds to make sure the app has quit, and then
    your actions to make the backup for the settings.
    A couple of ideas there.

Maybe you are looking for

  • Unable to check Null condition in a Shell Script

    Hi, When I am using to check the Null Condition To check for a Running Java Process its failing to check. I am using variable in a shell script DPID=$(ps -ef |grep - i java|grep -v grep) if [ "$DPID"="" ' ];then else fi If the DPID has Null value the

  • Problems in Query, error handling and sqlj

    I need some clarifications: 1. Can I use where clause in Insert query: for e.g: Insert into table_name (.., ...) values (.., ..) where id not in (Select Id from table_2 where name = ''); 2. Can I handle error in my query in sqlj file. For e.g unique

  • Illustrator CS6 64-bit dvaui.dll and msvcr100.dll crashing problem, any solution?

    First things first, trying to find a tech support Email address or phone number has been infuriating.  The "3-step support wizard" which results in "go to the forums" is also infuriating and insulting. I have a Windows 7 64-bit PC running CS6 64-bit

  • Why "fixedcolumn" doesn't work in tableview?

    Hi, I have a tableview which use iterator on BSP page. I set "fixedcolumn" attribute for one column in iterator->GET_COLUMN_DEFINITIONS       tv_column-columnname  = 'pvname'.       concatenate '' text-002 '' into tv_column-title.       tv_column-wid

  • Nano in Disc Mode!!??

    Hey there, I got my ipod a couple of weeks ago and all was fine till it wouldnt turn on yesterday. I reset the screen, with the menu and play button, the apple logo came up but then the screen display says "DISC MODE" and is in black and white. It is