Applescript won't run as .app but runs fine in AppleScript Editor

I'm an experienced web developer.. but total applescript noob. so forgive me if this is a silly question.
I'm calling my script it from Flash via fscommand to launch a PDF using finder, rather than a browser.
The script works great from AppleScript Editor when i hit run but when saved as a .app it doesn't run.
any ideas?
Here's the code:
property fileName : "my.pdf"
set myPath to (path to me as string)
set AppleScript's text item delimiters to ":"
set the parentFolder to ¬
((text items 1 thru -2 of myPath) & "") as string
set AppleScript's text item delimiters to ""
try
set targetFile to alias (the parentFolder & fileName)
on error
return quit
end try
tell application "Finder"
open file targetFile
end tell

A script application is actually an application bundle - a bundle is a kind of folder that gets treated like a single item (in this case, an application). Getting path to me results in a path that ends with a colon (since it is a folder), so when you try to use text item delimiters to get the container you are actually just stripping off the trailing colon, so the path built for your file won't point to the correct location.
As previously posted, the Finder can get the container, so you can just do everything in a tell application "Finder" statement:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #DAFFB6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
property fileName : "my.pdf"
set myPath to (path to me)
tell application "Finder"
set the parentFolder to container of myPath
try
open file ((parentFolder as text) & fileName)
end try
end tell
</pre>

Similar Messages

  • Mac Pro Dual Quad Core won't boot OS/X, but plays fine with Linux/Windows

    I've got a Mac Pro Dual Quad Core won't boot OS/X, but plays fine with Linux/Windows. I've tried all of the following initial tests as suggested on forums:
    -Ram swaps
    -Alternating video card in PCIe slots
    -Trying alternate video card
    -resetting pram and smc
    -Multiple tests with memtest86+ over 26hrs and no failed ram
    -Multiple tests (8-12 cycles) with apple HW diagnostics and no problems
    -Firmware is approved firmware for early 2008 model...no new updates.
    Gentoo livecd works fine and I even installed to hard drive and it boots fine with it. In addition to above tests I also ran a linux stress test putting all 8 cores at a load of 22 for 2.5hrs with no problems.
    Memtest86+ for 24hrs+ yields no problems.
    Where problems occur:
    Booting off hard drive, DVD or firewire yields an immediate curtain of death and booting off a new snow leopard DVD dies about 25% into the install.
    Looking at error log and a quick dmesg shows "Package 0 didn't get an HPET" and complains about AppleIntelCPUPowerManagement.kext. Google turns up illegal uses of this, so doesn't apply to my use case.
    I'm a bit stumped since all was working well until one day it was non-stop curtains of death and can't get them to go away.
    A logic board replacement at $1100 is not a feasible option for something that works on linux and windows, but not OS/X, is a bit disappointing and somewhat surprising.
    Thanks for your help and advice.
    Regards,
    Marcos

    Someone here once thought they knew EFI and Open Firmware a little, and used some commands from OF library that an Intel EFI Apple system didn't like. New logicboard.
    Of course to run or boot OS X and see video you need EFI based card. The presence of some PC cards can block OS X from booting.
    The fact you get part way through SL DVD, pull all the drives, put in a new drive and format it from SL DVD.
    Most of the things you tried are what are more common with PC hardware. Including where people have tried and failed to install OS X on unsupported hardware.
    I suppose it is possible something tried and failed to modify the Mac's firmware.
    If you have Windows running, and you have WD drives, WD just posted new Lifeguard utility which is what I use to do a good job of stripping a drive down and recertify it for reuse, works wonders. Maybe same for other makes with vendor utility.

  • Podcast episodes won't download in iTunes app (but works fine on desktop)

    Hi, I can't figure this out:
    Our podcast episodes simply won't download in the iTunes app on iPhone. The download simply stops at 10.3 kB (or sometimes at another value), without really getting started at all.
    This is very odd, since downloads are working fine in iTunes on the desktop, and in other apps on the phone (such as Instacast).
    Here's the iTunes-page for the podcast:
    http://itunes.apple.com/no/podcast/filmfrelst/id303539607?l=nb
    And here's the RSS feed URL:
    http://montages.no/filmfrelst_files/rss.php
    (The podcast is called "Filmfrelst", and is searchable in the iTunes app)
    Any clues?

    OK, seems like I located the problem - sort of.  It's not the feed that's the issue, but rather the fact that I'm pushing my MP3-files through a PHP script which does some statcounting. If I access the MP3 files directly, the iTunes app downloads them OK.
    So I'm guessing maybe my headers aren't exactly what the iTunes app is expencting? Here's a snippet from the PHP file which outputs the MP3 data:
    header('Content-Type: audio/mp3');
    header('Content-Length: 'filesize($location));
    @readfile($location);

  • My feed won't upload to iTunesU, but works fine if I subscribe to it through iTunes!

    Hello all!
    here's the problem:
    I have made a link to an xml file that won't upload to iTunesU through the public site manager, and won't be validated on FeedValidator.org.  
    Feedvalidator gives the message: server returned timed out
    iTunesU Public Site Manager returns the message that it can't download the feed from the url.
    HOWEVER,
    - the url to the xml file works perfectly in all web browsers - it is recognized as a feed and a working link to the video comes up right away.
    - I uploaded the xml and video file to a different website(not on the University's server) and iTunesU and feedvalidator recognize it as valid, and the content appeared on our iTunesU page straight away.
    - I was able to successfully subscribe to the feed (on the University's server) and download the video file using iTunes on my computer.
    I am thinking it has something to do with the permissions on our University's server, but the system admin and I have reached a dead end as far as solutions
    I'm getting pretty frustrated figuring this out, can anybody help?!??!
    It is greatly appreciated!

    Your feed definitely validates, I’ve entered it by direct input on the w3cfeed validator and it’s fine - http://validator.w3.org/feed/#validate_by_input. That suggests it’s definitely a server configuration issue. Could the server be blocking ports required by the validator or iTunes? I presume the validator and iTunes both use http port 80, in which case, as the feed renders in a browser there shouldn't be a problem. Is the server definately available to external users/applications ie off campus?
    Could it be a character encoding issue? I have downloaded your feed and opened it in notepad++ and it tells me the character encoding is 'UTF8 without BOM'. Not sure if it makes any difference but I use 'UFT8' for our feeds. I think servers can change character encoding depending on how they're set up which might account for the discrepancy.
    This is not connected to your original question but you're not using the itunesu name space in the rss element at the top of your feed. As you're not using any itunesu specific elements in your feed I'm not sure if it's needed but just thought I'd mention it.
    <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"xmlns:media="http://search.yahoo.com/mrss/" version="2.0"xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunesu="http://www.itunesu.com/feed">

  • Links within a pdf won't open in Safari, but work fine on Explorer, Firefox

    I created a pdf with embedded links and posted it to my site. The links within the pdf work just fine with Internet Explorer and Mozilla Firefox, but they will not open with Safari, neither on a Mac nor on a Windows platform.
    Why is this happening and how can I fix it?

    Hi and Welcome to Apple Discussions...
    Try this. In the Safari window, click the Preferences icon right side of page.
    Then select the General tab.
    At the bottom of that window, below, "Open links from applications", choose the option you want.
    Carolyn

  • Ipod won't update new software but works fine

    itunes has latest update trying to update my ipod but says that it has timed out every single time. Tried to restore it, and tells me the samething

    You need to get someone to help you turn off or temporiarly disable the anit-virus software (Norton, McAfee, AVG, Avast, Kaspersky, or what ever).

  • Safari won't bounce on dock but opens fine?

    It in itself isn't the issue but the only way I can reset the browser is to force quit.

    Ok...
    Might be corrupted Dock preferences.
    Go to ~/Library/Preferences
    Move the com.apple.dock.plist file from the Preferences folder to the Trash.
    Restart your Mac.
    See if that helps...
    ~ (Tilde) character represents the Home folder.
    For Lion:   To find the Home folder in OS X Lion, open the Finder, hold the Option key, and choose Go > Library

  • Won´t accept CD-R, but works fine with DVD (Combo-Drive)

    Hi there,
    my emac got stuck after using a audio-CD with a little scratch. After restart I introduced normal CD-R, but they just got ejected by themselves after a few strange noises and about 5 seconds. I put in the MAC OS X start-up DVD, and it worked perfectly.
    The question is: is there anything I could do, besides upgrading my eMAC after all to a Superdrive?
    Doing some reliable(?) Internet research, it looks, that that can´t be too hard, and my warranty has expired anyway. So the second question goes:
    Which brands and models are working fine? (Looks like Pioneer does, but only them?)
    Thanks a lot,
    Daniel.
    eMAC   Mac OS X (10.3.9)  

    Hi,
    I had the same problem on my 14 month old (under-used!) 1.25 combo, would read dvd fine but not cd-rw, I tried a cleaning disc and even took out drive to blow out any possible dust! still no luck.
    I then decided to go superdrive and put in a Pioneer 110D cd/dvd burner as this seemed the popular choice, I found installation easy, I left the jumper on back of cd burner on 'CS' as my original one was set to that. I then fired up emac and installed 'Patchburn 3' software patch available as a download from the internet to finish the installaton. So far it all seems ok!

  • HT201210 Can the OS for an iPod Touch be updated beyond 3.1.3?  iTunes tells me that this is the latest software but many apps won't run on this older os.

    Can the OS for an iPod Touch be updated beyond 3.1.3?  iTunes tells me that this is the latest software but many apps won't run on this older os.

    If you have a 1G (first generation) iPod touch then it can only go to iOS 3.1.3. To identify yours:
    Identifying iPod models
    If you need a higher iOS, you will have to get a newer model iPod.

  • My Silverlight app won't run in debug on 3.6.6 or 4 beta. I managed to find 3.5 and my app works. No clue why.

    My Silverlight 4 app won't run in debug on 3.6.6 or 4 beta. I managed to find 3.5 and my app works. No clue why. Sorry, my app is not on the web. I could zip up the whole project and send it to you if you're interested. It doesn't do much so far. Just started.
    == URL of affected sites ==
    http://

    Hi Tobbi,
    SL version 4. Reinstalled many times. Running Windows 7.
    Not sure exactly what version I was running prior to 3.6.6.
    Tried version 4 beta - didn't work. Found 3.5 and it works.
    When I run, I get the white screen with the dots going around in a circle forever (Silverlight loading thing). I could send you a screen shot, but I really don't want to go back to 3.6.6.
    I set a break point at the earliest possible place in my code and it never gets there.
    Thanks

  • I have os x 10.7.4 but somehow safari was not updated to 6.0 - safari won't run

    I have os x 10.7.4 but somehow safari was not updated to 6.0 - safari won't run
    Can I install safari only? Or need to install os x 10.7.4 again ??

    Try this link:
    http://www.macupdate.com/app/mac/15675/apple-safari/

  • 5800: apps missing / won't run / "key icon" overla...

    A few apps went missing on my 5800, also under Application manager. They're on the SD, and I think all Java. Some apps also started showing a small key icon overlayed at the corner of each app's icon. These apps can't be run.
    A restart didn't help, nor a restart without the card and a live reinsertion. After another restart the key icon overlays disappeared but these apps still won't run. They could only be reinstalled after an uninstall, but those that disappeared are stuck in limbo.
    Besides the above, one app that was preloaded on the card now has an empty icon, and after two restarts its name shows as a 9 digit number (see below). It can't be run.
    All of this on firmware v31. As far as I can tell I didn't do anything to trigger it.
    Are there any non-destructive ways to fix it?
    Is there a way to use Symbian without all these strange problems popping up all the time (with the usual solution seemingly being total reset/format)?

    ur symptoms lead to a diagnosis of corrupt memory card.. Have u installed any of those java programs from free game sites tht, while installin, says ur phone could be harmed? Coz those java games r a bit unstable on nokia5800.. I knw it shouldn't be.. But... It is.. Sometimes there's a read/write error and then they show key icons..
    Whatever to solve this, do this..
    Connect with computer
    When asked choose mass storage mode
    Open my computer
    U'l find ur memory card listed
    Right click, goto properties
    There's an option for check disc for errors
    Select tht and let it scan and fix errors
    After u r done, see if u can uninstall those in limbo.
    If not connect again in mass storage mode
    Go to ur computer settings and as to show hidden files, and also show important windows files
    Open ur memory card
    U'l find a FOUND.000 folder.. Delete it
    It's unusable by symbian os and it takes on space
    Restore ur hidden file settings to normal.
    Hope this helps..
    Regards,
    Dr. Shoubhik

  • Many apps won't run any longer on yosemite

    All of a sudden on my iMac with Yosemite, many apps won't run, Word, PhotoShop Elements, TrueCrypt .... most are not
    64 bit, but what happened with update it the last week that would cause this

    If you have a 1G (first generation) iPod touch then it can only go to iOS 3.1.3. To identify yours:
    Identifying iPod models
    If you need a higher iOS, you will have to get a newer model iPod.

  • Automator app won't run from double-click

    automator app won't run from double-click in finder or from alert from ical. Will only run if I open in automator editor.
    I found a solution on my own. I opened activity monitor and all the automator apps that I run daily were hanging up and the auromator launch was hanging up. I force quit them from the activity monitor. Now it works again.

    I might have gotten there eventually on my own, but I suspect finding your post saved me a lot of work. Thanks for posting your solution.

  • Pismo now won't boot into X (but runs 9.1)

    I originally upgraded PBG3(FW)(pismo) to panther about a year ago. All was well and it worked without any problem.
    Then at the suggestion of software update I did one of the security updates (to be honest i can now no longer remember which one) and after that it crashed and refused to boot.
    It will not boot from my panther CD - sometimes gets as far as the grey apple and spinning disk, then stalls.
    It will boot from a backup 9.1 CD and I can re-install 9.1 on the HD, which then boots and runs normally (wow its fast).
    From within 9.1 the panther CD mounts and verifies normally. In startup disk it is greyed out so i can't chose to start from it. If I launch the installer it tries to restart but won't and gives an error to the effect of not being able to startup from the startup CD.
    It will not boot from a clone of my PM G4 installation from a firewire HD.
    The panther CD will startup the G4 (so it must work) and I can install panther on the pismo HD when it is in FW target disk mode. But the pismo will still not then boot from this install.
    Its as if something in the update stopped the poor pismo from starting up from any version of X. No other hardware changes made between it being OK and now refusing to boot.
    Any help very gratefully recieved !
    Pismo 400MHz
    firmware upgraded
    ugraded to 320 Mb RAM (checks out OK on one RAM tester)
    New 20G HD
    boxed retail panther
    Pismo ! Mac OS 9.1.x
    iMac G5, PB G4, PMG4, Pismo !   Mac OS X (10.4.4)  

    Hi Jon:
    Good call on removing the RAM, which is often a culprit of kernel panics, and you're right, Panther does need at least 128MB to run. You could try another stick of RAM (I'd recommend Kingston or Azen)....
    I've installed Panther on close to 50 mac of various flavors in the last two years, everything from 350 MHz iMac to a dual 2GHz PowerMac G5, and have rarely encountered a problem that couldn't be resolved with a simple hardware change (RAM, optical or hard drive). Right now, as it turns out, I'm having problems with a 350MHz iMac. Panther installs ok, all the updates go ok, all the installed apps run fine, but as soon as I try to change the screen saver, it freezes. I've wiped the drive, written zeros, and reinstalled, and both times I get the exact same thing. I've swapped RAM, which makes no difference, so I'm about to try a different hard drive.
    Let us know how replacing the mach_kernel file goes, and good luck!
    Andrew

Maybe you are looking for

  • Drop shadow on text in table

    Is there any way to give text in a teable a drop shadow without giving the stroke of the table a drop shadow?

  • Applet tiff viewer

    hi, Can any body give some sample code or idea how can display tiff image or tiff file in a web browser. Thanks in advanced.

  • How to trace WAD problems

    Hello, Is there any procedure to trace the WAD (webapplication designer)activities/errors etc.... By seeing the Trace file of WAD, i can realize the exact problem of errors.. Please let me know how can i do this? Thanks ravi

  • Expende the Line in the result list

    Hello I need your help. In the result list at "Identify account" i get only 4 lines. and if i have 10 result i need to turn pages. I want to get more then 4 lines in the result list in one view without turn pages. Thanks Merav

  • My iphone 3g 3.1.3 wont update at all?

    Hi ive got an iphone 3g 16gb its on firmware 3.1.3. Ive been trying since i got it to update it through itunes but it just wont let me.Ive downloaded through itunes 4.2.1 and tryed to install it but it gets to near the end and get error code 1015? i