• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: applescript uninstaller delete itself & customizing applescript application bundle binary filename (CFBundleExecutable)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: applescript uninstaller delete itself & customizing applescript application bundle binary filename (CFBundleExecutable)


  • Subject: Re: applescript uninstaller delete itself & customizing applescript application bundle binary filename (CFBundleExecutable)
  • From: Axel Luttgens <email@hidden>
  • Date: Tue, 17 Apr 2007 16:29:57 +0200

On 16/04/07 20:36, Jason Danielson wrote:
On 4/14/07, Axel Luttgens <email@hidden> wrote:

[...]

[...]

if there is a way to do this without using variables, or if there is a way to use variables and not have the script save itself then please let me know.

Hello Jason,

Looks like Kai already came with the answer to this one. ;-)

[...]

I'm a bit lost with your description here...
Again, some more info would be welcome! Could you for example provide us
with a short sample code just sufficient to reproduce the symptoms?


    set tempPath to POSIX path of (path to "flnt" as string) & "uninstall.app/"
    set tempPathEx to POSIX file tempPath
    set myPath to POSIX path of (path to me as string)

    if not (myPath = tempPath) then
        -- obtain confirmation
        display dialog "This will fully uninstall Product from your system. Are you sure you want to continue?" with title "Uninstall Product" with icon caution buttons {"Cancel", "OK"} default button 1
       
        do shell script "rm -rf '" & tempPath & "'"
        do shell script "cp -R '" & myPath & "' '" & tempPath & "'"
        ignoring application responses
            tell application "Finder" to open tempPathEx
        end ignoring
        return
    end if

    display dialog "script running from temp location"


if you compile this script as an application bundle and run it from anywhere, it should copy itself to a temp location just fine but fail to run the copy half of the time. try running it several time and you should see the final dialog "script running from temp location" every second time you run it. i have no idea why it only works half the time.

[...]

Thanks for having provided that example code.
Indeed, that's an interesting one...

I don't believe the "ignoring..." and "end ignoring" statements are needed here: unless I'm wrong, the Finder handles the open command asynchronously when applied to filesystem objects, so that the control returns immediately to the caller (this also means that the open command may silently fail).

This said, the problem isn't ***directly*** related to the fact that the copy is made to a temporary location (as you wrote in your previous post).

As a "proof", please create folder "jasonf" on your desktop but ***leave it closed***, and replace:
    set tempPath to POSIX path of (path to "flnt" as string) & "uninstall.app/"
with:
    set tempPath to POSIX path of (path to desktop as string) & "jasonf/uninstall.app/"
Unless our boxes are very different, you should still get that weird behavior (working half of the time).

Now, show the contents of folder "jasonf" in the Finder (for example, open it in a new window) and run the application again several times: no failures any more...

This suggests a slight change to the code; let's replace:
    tell application "Finder" to open tempPathEx
by:
    tell application "Finder"
        update container of tempPathEx
        open tempPathEx
    end tell
Fine: no failures anymore, even when the contents of folder "jasonf" isn't displayed.

OK, let's thus revert to the temporary location, by replacing:
   
set tempPath to POSIX path of (path to desktop as string) & "jasonf/uninstall.app/"
with:
   
set tempPath to POSIX path of (path to "flnt" as string) & "uninstall.app/"
Damn... the weird behavior is back.

Yet, using the Finder's "Go to folder..." menu item so as to display the contents of the temporary folder while running the application, everything works as expected
again.

Looking at the definition for "update "in Finder's dictionary, let's then replace:
    update container of tempPathEx
by:
    update container of tempPathEx without necessity
in spite of what the dictionary seems to say about default values.
Hmmm... works again, wheter the temporary folder's contents is displayed or not.

So, just to make sure I didn't manage to just confuse everyone, here is your script's amended version that works for me:

    set tempPath to POSIX path of (path to "flnt" as string) & "uninstall.app/"
    set tempPathEx to POSIX file tempPath
    set myPath to POSIX path of (path to me as string)

    if not (myPath = tempPath) then
        display dialog "This will fully uninstall Product from your system. Are you sure you want to continue?" with title "Uninstall Product" with icon caution buttons {"Cancel", "OK"} default button 1
        do shell script "rm -rf '" & tempPath & "'"
        do shell script "cp -R '" & myPath & "' '" & tempPath & "'"
        tell application "Finder"
            update container of tempPathEx without necessity
            open tempPathEx
        end tell
        end ignoring
        return
    end if

    display dialog "script running from temp location"

As a side note: it looks like the problem may be circumscribed to the interaction (or a lack of) with launch services, as replacing:
   
update container of tempPathEx without necessity
with:
    update container of tempPathEx with registering applications
provides a fully functional version too.

As far as the location of the copy is concerned, it seems that it the visibility of the enclosing folder that makes the difference: "jasonf" is a visible item, "Cleanup At Startup" is a hidden one.

But this still doesn't tell the whole story: how can that systematic "1 out of 2" behavior shown by your original script be exactly explained?
I haven't yet managed to get a clear picture...

Axel
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: applescript uninstaller delete itself & customizing applescript application bundle binary filename (CFBundleExecutable)
      • From: Axel Luttgens <email@hidden>
References: 
 >applescript uninstaller delete itself & customizing applescript application bundle binary filename (CFBundleExecutable) (From: "Jason Danielson" <email@hidden>)
 >Re: applescript uninstaller delete itself & customizing applescript application bundle binary filename (CFBundleExecutable) (From: Axel Luttgens <email@hidden>)
 >Re: applescript uninstaller delete itself & customizing applescript application bundle binary filename (CFBundleExecutable) (From: "Jason Danielson" <email@hidden>)

  • Prev by Date: Delete layer in Photoshop
  • Next by Date: Re: Delete layer in Photoshop
  • Previous by thread: Re: applescript uninstaller delete itself & customizing applescript application bundle binary filename (CFBundleExecutable)
  • Next by thread: Re: applescript uninstaller delete itself & customizing applescript application bundle binary filename (CFBundleExecutable)
  • Index(es):
    • Date
    • Thread