Need help w/ applescript to restart, launch an app, restart, then repeat

Hey Everyone,
Ok. I want to write an AppleScript that will do the following:
1) restart computer
2) launch 1st app for x sec.
3) restart
4) launch 2nd app for x sec.
5) restart
6) launch 3rd app for x sec.
6) restart
However, the only code I've been able to find that restarts the computer is the following:
tell application "Finder"
restart
end tell
While this does restart the computer, I can't find a way to integrate it with my "sub" AppleScript that launches the app. So far, my script only does the following:
1) Launch 1st app for x sec
2) Restart
I'm having problems launching things automatically after a restart. Does anyone have any suggestions?
thanks,
--Jonathan

The fact that you restart the machine automatically terminates your script, which is why you don't continue after the restart.
What you will need to do is use some persistent data to keep track of the iterations. You will then need to add your script to the login items (so it's launched the system restarts) and it can use its persistent data to know how many restarts it has done. For example (untested):
property numRestarts: 0 -- this will be the restart counter
on run
  if numRestarts = 0 then -- first run
    set numRestarts to 1
    tell application "System Events" to restart
  else if numRestarts = 1 then
    tell application "App1" to activate
    delay 120 -- wait 120 seconds (two minutes)
    set numRestarts to 2 -- increment the counter
    tell application "System Events" to restart
  else if numRestarts = 2 then
    tell application "App2" to activate
    delay 120 -- wait again
    set numRestarts to 3
    tell application "System Events" to restart
  end if
  -- add more cases here
end run

Similar Messages

  • I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    What file format did you export it to?

  • Hi i need help please . when i want to buy app from store ask me the security question but i forgot the answer  so i need to the link to rest answer of security question

    hi
    i need help please . when i want to buy app from store ask me the security question
    but i forgot the answer
    so i need to the link to rest answer of security question

    The Best Alternatives for Security Questions and Rescue Mail
        a. Send Apple an email request at: Apple - Support - iTunes Store - Contact Us.
        b. Call Apple Support in your country: Customer Service: Contact Apple support.
        c. Rescue email address and how to reset Apple ID security questions.

  • I bought a ipod touch 3 i need help on this is there a youtube app that has a cach download to play youtube video's offline within the app if there is one can someone fill me some info on this matter

    i bought a ipod touch 3 i need help on this is there a youtube app that has a cach download to play youtube video's offline within the app if there is one can someone fill me some info on this matter

    You can only use apps that are compatible with your dvice and ios version.
    The secons gen ipod touch can only go to 4.2.1.
    If you are running 4.2.1 then you can only use apps that require 4.2.1 or lower.

  • I need help with AppleScript for changing the font on numerous PowerCADD files

    I am currently trying to write an AppleScript, but I really have no idea how one is written.  I have looked up many tutorials, but to no avail.
    What I'm trying to so is write a script that will take all my selected PowerCADD files, open them, change the font to Helvetica, then save the file.  I have over a thousand files to do this to.  So, you can see my need of an AppleScript to get this task completed.
    If anyone out there knows how I would write this script, please submit it here.
    Thank you so much for your time and help.

    If anyone could help, that would be awesome  =)

  • Need help FAST Application refusing to launch

    My PowerBook is refusing to launch an app, the app works fine on all my other computers. In the app's crash log I get this:
    http://pastebin.com/664099
    This computer used to run the app fine until earlier today when a folder named 501.xxxxxxxxxxxxxxxx (the x represents numbers that I can't remember). I am loosing my patients with this **** computer and am about to smash it with a hammer if I don't get this fixed FAST.
    --Thank you for your help

    If you really want this fixed fast, you should consider:
    The more information you provide about the crash, the better. You didn't indicate what program you were using and you also seemed a bit frustrated when you posted and didn't quite finish the sentence concerning the 501 folder, which I can only assume, appeared in your trash, as I think I've seen this before after a program quits unexpectedly.
    According to the crash report, it appears that the program that is crashing is Adium.
    You can try reinstalling the program to see if something has been corrupted in the program package.
    You can check to see if there is a more up to date version of the program. You might be dealing with a bug that has been fixed in a more recent version.
    You can hunt for the preferences by doing a file search in the library/preferences folder to see if you can find all the preferences associated with adium and delete them. You will most likey loose all your preference setting and any login information, since it's an IM program, but at least you can get it up and running again.
    Don't delete the preference files until you have verified that the other two solutions do not work. There's no need to go through re-intering the preferences you want if you can fix the problem by reinstalling the program, which doesn't mess with your preferences.

  • Need help setting up svnserve to launch automatically.

    Last night I created a svn repository on my iMac.  I imported an svn dump into it and I was able to access my code from localhost and a remote machine (same LAN) using Versions.  But I then set up a LaunchDaemon and access via _svn user and now I get errors. HELP!!  I am getting a malformed data error. 
    I used this code: (stupidly on my Snow Leopard 10.6.8 machine)
    But instead of running it manually, we can run it automatically when the server Mac starts up by using launchd. You can read up onGetting Started with launchd, but basically it's the new startup process in Mac OS X 10.4 (Tiger). So, to start svnserve automatically, create the file /Library/LaunchDaemons/org.tigris.subversion.svnserve.plist, and put the following in it: 
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
        <dict>
            <key>Disabled</key>
            <false/>
            <key>Label</key>
            <string>org.tigris.subversion.svnserve</string>
            <key>UserName</key>
            <string>svnuser</string>
            <key>ProgramArguments</key>
            <array>
                <string>/usr/local/bin/svnserve</string>
                <string>--inetd</string>
                <string>--root=/Users/svnuser/svn</string>
            </array>
            <key>ServiceDescription</key>
            <string>Subversion Standalone Server</string>
            <key>Sockets</key>
            <dict>
                <key>Listeners</key>
                <array>
                    <dict>
                        <key>SockFamily</key>
                        <string>IPv4</string>
                        <key>SockServiceName</key>
                        <string>svn</string>
                        <key>SockType</key>
                        <string>stream</string>
                    </dict>
                    <dict>
                        <key>SockFamily</key>
                        <string>IPv6</string>
                        <key>SockServiceName</key>
                        <string>svn</string>
                        <key>SockType</key>
                        <string>stream</string>
                    </dict>
                </array>
            </dict>
            <key>inetdCompatibility</key>
            <dict>
                <key>Wait</key>
                <false/>
            </dict>
        </dict>
    </plist>
    I also used these commands to give the _svn user acces to my repository.
    sudo chown -R _svn:_svn /Volumes/Development/svn
    sudo chmod -R ug+rwX,o= /Volumes/Development/svn
      sudo launchctl start org.tigris.subversion.svnserve
    Before I did these things, everything worked beautifully, just I had to start the server manually after reboots.
    Now, I can't even access the repository anymore.
    I need help to get my work back online!

    If the iPhone is no longer activated with cellular service, they are not text messages as in SMS/MMS. They are iMessages which can be sent to a phone number activated with iMessage or to the Apple ID that is activated with the phone number with iMessage on an iPhone.
    Signing out of the Apple ID with the iTunes and App Store on an iPhone is seperate from signing out of the Apple ID with iMessage and FaceTime.
    All apps include DRM protection that is tied to the iTunes account or Apple ID that was used to download the apps. The only way the person you are giving the iPhone to will be able to download an app update for any apps on the iPhone that were downloaded with your Apple ID will be using your Apple ID and password.
    Music and apps currently installed on the iPhone will not be removed.
    To sign out of your Apple ID with iMessage, go to Settings > Messages > Send & Receive > Apple ID. Select the Apple ID and at the window that appears, select Sign Out. Sign in there with the new Apple ID that will be used by the person you are giving the iPhone to. Do the same with FaceTime on the iPhone.

  • Hi I can't buy game add on for any games need help I can buy from iTunes and App Store but not from games

    Hi need help with cant buy game add on can buy from iTunes but not any game add on need help

    To Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact
    Note:
    Some In-App Purchases require a Credit Card.

  • Need help modifying Applescript to copy "Spotlight Comments" into file

    Hello all,
    I have a very large batch of images of Leonardo da Vinci's notebooks. I used the "Spotlight Comments" field of each file to save information about the notebook page depicted in each image:
    Well, I had to modify each image in Photoshop and when I saved the files, Photoshop of course didn't retain the Spotlight Comments. Now, before I modified the images, I duplicated the directory, so I have a copy of all of the images that retain their Spotlight Comments field with each image's information. What I want to do is copy the text from the Spotlight Comments field of the original files and either paste this text into the Spotlight Comments field of the modified files (which are in a different directory, but retain the same filenames as the originals), or at least copy the text from the Spotlight Comments field of the original files and paste each block of text into a txt file with a couple of blank lines in between each entry, so that I can manually copy/paste the citations into the modified image's Spotlight Comments fields.
    I successfully used this Applescript:  https://discussions.apple.com/message/6741062#6741062
    to get the Spotlight Comments from the original files, but it displays them one by one in pop-up dialog boxes and because I have almost a thousand images it is extraordinarily wearisome to copy the text from each pop-up, paste it into a text file, make two blank lines, click "OK" in the pop-up to get the next one...
    Can anyone suggest how I can modify the code I have to tell the Finder to copy the contents of each pop-up and paste them into a single text file with a couple of blank lines between each entry?
    I have the barest, most rudimentary knowledge of Applescript, which is why I'm asking if one of the wizards here can help me modify or write an Applescript to do what I need to do.
    Thank you so much!
    BTW, here is the code from the aforementioned discussion that gets the Spotlight Comments from files. I made into an Applescript application using Automator:
    tell application "Finder"
    repeat with tItem in input
    set (comment of tItem) to (text returned) of (display dialog "Spotlight Comment: " default answer (comment of tItem as string))
    end repeat
    end tell

    Hi,
    Evan Izer wrote:
    Now, before I modified the images, I duplicated the directory, so I have a copy of all of the images that retain their Spotlight Comments field with each image's information. What I want to do is copy the text from the Spotlight Comments field of the original files and either paste this text into the Spotlight Comments field of the modified files (which are in a different directory, but retain the same filenames as the originals)
    This script does exactly that:
    set sFolder to (choose folder "Select folder wich contains original images.") as string
    set dFolder to choose folder "Select folder wich contains modified images."
    tell application "Finder"
          repeat with tItem in (get document files of dFolder)
                set origFile to sFolder & (get name of tItem)
                if file origFile exists then
                      set origComment to comment of file origFile
                      set comment of tItem to origComment
                end if
          end repeat
    end tell

  • Hi i need help with applescript to stop downloads when vpn fails

    I am an apple script novice, I would like to be able to have a script run all the time to detect vpn failures and close transmission when this happens:
    so far:
    on idle
              do shell script "ifconfig -lu"
              if "ifconfig -lu" contains "tun0" then
              else if "ifconfig -lu" does not contain "tun0" then
                        tell application "System Events"
                                  tell application "Transmission"
                                            quit
                                  end tell
                        end tell
              end if
    end idle
    it closes transmission and nothing else.  tun0 is my vpn interface and seemed the most fireproof way of understanding the state of the vpn connect.  When VPN is down tun0 doesnt exist.  Please help.
    many thanks

    There are several things wrong with your script.
    First, the glaring one:
              if "ifconfig -lu" contains "tun0" then
    This will never, ever, ever be true. What you're asking AppleScript is whether the string "ifconfig -lu" contains the string "tun0". Never going to happen. Not even close.
    What you really mean is whether the output of the shell command 'ifconfig -lu' contains 'tun0'. The easiest way to do that is to capture the output of the do shell script command in a variable and then test the variable, not the literal string:
    set activeInterfaces to do shell script "ifconfig -lu"
    if activeInterfaces does not contain "tun0" then
      -- stuff goes here
    end if
    Now AppleScript runs the shell script and puts the result in activeInterfaces which you then test to see if it contains (or, in this case, does not contain) the string you're looking for.
    Note that I've also reworked your if statement.. there's no need to have an empty 'if' clause followed by an else if that checks the opposite... by definition if the first one fails the second one will be true.
    Also note that there's no need to tell System Events to tell another application to quit - you can just do that directly.
    Next up is that you don't exit your own script after you quit Transmission. So now you have the scenario where the VPN drops, your script detects it and tells transmission to quit. However, your script keeps running so it then rechecks whether the tunnel is up... since it presumably isn't, it then relaunches Transmission in order to tell it to quit again. Then it rechecks whether the tunnel is up, if it isn't, it relaunches Transmission to tell it to quit... then it rechecks... you get the idea.
    Ideally you should tell your own script to quit after Transmission has exited so that you're not stuck in this loop.
    Lastly you don't include a return value in your idle handler. This means that your idle handler will run every 30 seconds. That might be good enough, or you might want to check more or less frequently. Just return a value indicating the number of seconds to pause between iterations -  realise that the more frequently you check, of course, the more load you put on your system
    Adding that all up you'll end up with something like:
    on idle
              set activeInterfaces to do shell script "ifconfig -lu"
              if activeInterfaces does not contain "tun0" then
                        tell application "Transmission" to quit
                        tell me to quit
              end if
              return 30 -- 30 is default value, but it doesn't hurt to include it here
    end idle

  • Need help creating applescript to perform automator actions.

    Hi,
    I am looking for help with an applescript the will tell automator to execute  the steps of a workflow.  I'm aware that I coud just run a workflow or even tell applescript to instruct automator to run the workflow, however, I am looking to make this part of a larger workflow and this method would save the hassel of having to create a new workflow outside of applescript each time.
    I would like automator to "get folder contents" then "extract pdf text" to a "new file" with the "same name as original file" in the "same location as original" and "save as txt".  This doesnt seem to difficult to me, however, I have limited knowledge of scripting at this time.
    I appreciate anyones help...

    Hi,
    I'd say on a difficulty scale of 1-10, what you're asking for is a seven.
    Automator is scriptable, but when you run a basic AppleScript like
    tell application "Automator" to make new workflow
    you immediately get taken to the dialog asking you to choose a type for your document (app, calendar plugin etc). So that's going to stop the AppleScript dead in its tracks. It might be possible to move on with GUI scripting (using AppleScript to click the buttons) but it would be a ferocious cludge.
    I think the best approach would be to manually create an empty action as a starting point. You would then need an AppleScript that would duplicate the workflow file (so you've got a fresh one to duplicate next time), open it in Automator, add the appropriate actions, set the settings etc.
    It all sounds a bit too complicated
    HD

  • Need help with applescript and Xcode 4.3.2

    I'm trying to write my first application that will involve a GUI. I can code applescript using script editor with a bit of effort, but I'm want to have users input more than one piece of information in the pop up. So, I download xcode, create my first applescript cocoa project go to MainMenu.xib and add a bunch of labels, text fields and buttons. Looks fairly nice... Go to start it and... nothing (well the window pops up, but it doesn't do anything). Unfortunately, I haven't figured out how to link the window to the applescript... So, how do I...
    * Have the applescript prepopulate data in the text fields and pulldowns
    * Once the user changes the data in the fields tell the applescript
    * Tell the window to close and pass the control back to the applescript once either the cancel or submit button is pressed.
    More detailed...
    * What's an outlet and how do I use it here? Which of the 18 outlet(s) do i use for this?
    * What's a property (referenced on one of the web pages I saw around applescript and cocoa) and do I need them here?
    Looking at the documentation with xcode, there isn't a lot about xcode and applescipt. Looking at the web, the top links are a few years old. So, links to good relevent documentation would be very nice as well as direct answers to the questions
    Thanks,
    Scott

    I'm not sure why you are closing it, but the NSApplication class is what keeps track of the windows.  If you don't want to connect the window to an outlet from the interface editor, you can use something like
    set theWindow to current application's NSApplication's sharedApplication's mainWindow()
    ...and from there you can use whatever NSWindow methods, for example
    theWindow's performClose_(me)

  • VoiceFx tab is gone, need help!! creative console launcher.

    Hello!
    I have the Creative Sound blaster X-fi Fatalty titanium champion card.
    In my old computer with win XP 32bit, the creative console launcher window had a setting for microphone in the "game mode" window to enable the voiceFX to change my voice.
    But with my NEW computer with win 7 64, i kept the exact same sound card cause i think its awesome, everything works great exept the microphone tab dont show, its just have the tabs named
    "headphones",
    "SPDIF/O",
    "Digital I/O" and
    "Encoder"
    the microphone tab used to be between the "SPDIF/O" and "Digital I/O".
    I DO USE THE LATEST DRIVERS, and i have tried several times to completly swipe all drivers and reinstall them but no luck, same **bleep**. i also tested it before i updated the drivers from 07, to 08.
    please help im lost, i really miss to be able to prank people with this stuff.

    My Friend ?neither equalizer, eax effects, crystalizer,nothing on concole launcher options works on digital output(SPDIF)
    these options just works on analogue sound mode

  • Need help creating applescript

    If anyone can help me figure this out. I would really appreciate it. I can't write scripts from scratch but I know how they work and I know enough to get myself into trouble.
    I would like to create a script that would automatically produce a printed filmstrip of 4 photos. It's essentially a photo booth for my wedding.
    My canon 50D tethered to my macbook pro with a wireless remote. Every 4 photos will be resized and stacked onto a 2x6 (600px by 1800px) Image with a PNG image (logo and frame) with transparency placed over top of it. I would like to keep a copy of the original pictures and the created film strip.
    The EOS Utility already drops all pictures into a pre-setup folder.I am thinking that the script should be linked to a folder on the desktop and when picture 1 is placed in the folder the scripts starts to add the pictures. After picture 4 it should save the final product to another folder then delete allowing photo 1 of the next set to repeat. Once the final picture is dropped in the last folder. A simple automator print photo action can be used.
    If you can help me please. let me know. Thank you.

    What you're imagining is a pretty complicated, involved script. Were you to write it, you could quite possibly sell it to others!
    If I were you, I would first look around online and see if there is any software already to do this.
    Next, I would experiment with Ps actions and see if there was something that looked like an easy way to do this (a "watch me do"-style method would be best, probably).
    Sorry I can't be of more help.
    Good luck!
    -Nate

  • Need help using applescript to export a playlist

    I'm trying to use applescript to get iTunes to export the current playlist as XML. I know this can be done via the File ->Export menu but I'd like to script this.

    Hi William,
    Sorry about that! Ok I just typed "xml" into the "search scripts" box in the top of the page. Take a look at the first couple of entries...or I linked the first two here:
    http://www.dougscripts.com/itunes/scripts/ss.php?sp=exportselectedtracksxml
    http://www.dougscripts.com/itunes/scripts/ss.php?sp=exportsmartcriteria
    Let us know...
    Reg

Maybe you are looking for

  • JS/CS3 or 4:Geometry for texts

    Dear All, I had a requirement to get the geometric bounds for some key terms in texts (Eg. Key words, URL, etc). Is there any possibility to get the geometric bounds for inline texts? If so, kindly let me know. regards Masthan

  • Paid for same subscription multiple times - Refund?

    hello, on 16 th of July, i did pay 3 times one subscribtion for unlimited calls to Canada. How can i have my money back? thank you. [Topic title updated by moderator to be more descriptive. Original topic title was: "Subscriptions"]

  • Constraints between two or more tables

    Dear all, I have a general question, i searched in Google but i couldn't find any result. if i want to add constraints to a table it is easy , but what if in this "Check " part, i also want to consider records from another table? how it is possible?

  • SOA Suite 11g composite application deployment to SOA cluster?

    What is the best practice for 11g composite app deployments to a SOA cluster? Currently, when customer deploys SOA composite it only gets deployed to one of the SOA managed servers in the cluster and the only way for them to sync up SOA1 and SOA2 is

  • When material price changed (sd item conditions)

    Hi all, when material price changed in the time that is used in an sd order and when this order's delivery has been created.. the order's item's material's price has been changed before invoice printed(assume item as 10 and material assume as 600300)