Re: applescript uninstaller delete itself & customizing applescript application bundle binary filename (CFBundleExecutable)
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: "Jason Danielson" <email@hidden>
- Date: Mon, 16 Apr 2007 11:36:05 -0700
On 4/14/07, Axel Luttgens <email@hidden> wrote:
Well, it isn't that ugly... ;-)
(I'm not speaking here about the delicious idea of a suicidal program)
The script, while running, is in memory; when it finishes, it tries to
write its new state back to its file, if needed.
This means that your script has something to write back: properties or
global variables whose values have changed.
Perhaps would it be possible to avoid that error message by just
avoiding those changing properties and/or globals.
But I agree, I am just guessing here, as a lot of info is missing (which
OS version, which programming environment, how does the script get
invoked, how is it written...?).
OS: right now we're supporting
10.4
environment: i'm just using basic applescript so i'm not sure what environments apply
invoked: run by a user attempting to install / uninstall. it is compiled as an application bundle so that it can be simply run as a stand-alone program.
written: as a basic text file that is programmatically compiled using osacompile
i had noticed that i wouldn't get the ".... -43" error message when i wasn't using any variables. but part of the script has to iterate through all users and remove any user-specific application data. the only way i could find to do this is to set a few variables that define paths to the location of potential removables:
-- remove all user-specific data set users to do shell script "ls /Users"
set AppleScript's text item delimiters to ASCII character 13 set users_list to text items of users
repeat with i from 1 to count users_list
if not (item i of users_list = "Shared") then set itiva_s to "/Users/" & item i of users_list & "/Library/Application Support/OurData"
set itiva_p to "/Users/" & item i of users_list & "/Library/Preferences/OurData"
do shell script "if [ -d '" & itiva_s & "' ]; then rm -rf '" & itiva_s & "'; fi" with administrator privileges
do shell script "if [ -d '" & itiva_p & "' ]; then rm -rf '" & itiva_p & "'; fi" with administrator privileges
end if end repeatif 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.
Perhaps could you try something like this from your main script:
do shell script "{ sleep 10; rm -fR /path/to/the/app; } >/dev/null
2>&1 &" with administrator privileges
i tried this and it seems to work. GREAT! we would, however,
have to get rid of the uninstall success dialog so that the script
could quickly exit before the deletion occurs. but awesome and
thanks. this is totally an acceptable solution. but if anyone has an answer to the first problem i'd still like to know.
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.
however, because of your suggested solution above which puts us in the best working state so far, this issue of running a script from a temp location can now be reduced to curiosity level. i'd still like to know why it only works half the time.
Let's say you want to have "jason" instead of "applet" appear into the
prompt.
After some trials and errors, this seems to work here:
1. Save your script as application bundle "jason" (do not check the
"executable only" box) and close its window in SE.
2. In the bundle's
Info.plist, replace every occurence of "applet" with
"jason".
3. For every file having "applet" in its name, replace that string by
"jason".
4. Re-open the bundle in SE.
5. Re-save it from SE.
6. Double-click the bundle; the prompt should now be "jason requires
that...".
You may now replace the bundle's main.scpt by any other script, for
example by its "executable only" version.
from reading your algorithm i discovered that there was a file named "applet.rsrc" that i hadn't renamed to the desired title along with the "applet" binary. renaming this makes it work. i should note that i didn't have to go through the full procedure that you mentioned. simply compiling once, changing
Info.plist and renaming the two files "Contents/MacOS/applet" and "Contents/Resources/applet.rsrc" worked for me.
but thanks for pointing me in the right direction.
---
Jason Danielson
Itiva Development Corp
_______________________________________________
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