RE: Checking to see if the app is open before installing
RE: Checking to see if the app is open before installing
- Subject: RE: Checking to see if the app is open before installing
- From: "Glover,David" <email@hidden>
- Date: Fri, 21 Nov 2008 10:29:38 -0000
- Thread-topic: Checking to see if the app is open before installing
Thank you very much guys for your advice on this matter - very useful
and interesting info, and much appreciated!
-----Original Message-----
From:
installer-dev-bounces+david.glover=email@hidden
[mailto:installer-dev-bounces+david.glover=email@hidden
le.com] On Behalf Of Bill Coderre
Sent: 20 November 2008 23:44
To: Glover,David
Cc: email@hidden
Subject: Re: Checking to see if the app is open before installing
On Nov 20, 2008, at 1:58 AM, Glover,David wrote:
> I've been having a look around to find some information on upgrading
> an app bundle when it is already open on the machine, but haven't
> really found anything.
> I was wondering if it is best practice to check that any apps being
> upgraded at install time are closed, and if not, quit the install /
> close the open app? Has anybody else come across this, or do
> something similar? Is it really necessary, or is it overkill?
> I guess it wouldn't be too difficult to do in a preflight or
> preinstall script, but more to the point, is there any point! :o)
So I wrote the code that Apple uses, and yes, it's a good idea for
applications to be quit during an update. Mac OS X Applications store
persistent UI objects in containers called "NIBs" -- menus, windows,
alert panels, etc, are all in NIBs. (Cocoa Nibs, geddit?)
The problem stems from the fact that NIBs do not have to be loaded at
program launch time (and avoiding loading stuff makes programs launch
much faster!). So if your updater changes, say, the NIBs connected
with printing, they might not get loaded before the update happens. So
your old binary executable (which is still running) might end up
calling a new NIB, causing a crash, or misconnected menu items that no
longer work, etc.
Here's the code I wrote for iLife. You might not need something this
complicated.
The distribution JavaScript function
system.applications.fromIdentifier() takes a bundleID and returns non-
null if the program is running. (Documentation:
http://tinyurl.com/5afn9d
)
Also, JavaScript has nice strings objects (see "replace", below). (Oh
wait, now I see the documentation for localizedStringWithFormat, and I
could've made that function much simpler!)
> // Make sure apps aren't running
> var IDArray = [ 'com.apple.iPhoto',
> 'com.apple.iMovie',
> 'com.apple.iMovie7',
> 'com.apple.iMovieHD',
> 'com.apple.iDVD',
> 'com.apple.garageband',
> 'com.apple.iWeb',
> ];
>
> var NameArray = [ "APPNAME_IPHOTO",
> "APPNAME_IMOVIE",
> "APPNAME_IMOVIE",
> "APPNAME_IMOVIEHD",
> "APPNAME_IDVD",
> "APPNAME_GB",
> "APPNAME_iWeb",
> ];
> var numAppsRunning = 0;
> var OneAppRunning = "";
> var ManyAppsRunning = "";
>
> for (var index = 0; index < IDArray.length; index++ )
> {
> if (system.applications.fromIdentifier(IDArray[index]))
> {
> numAppsRunning++;
> OneAppRunning =
system.localizedStringWithFormat(NameArray[index]);
> ManyAppsRunning = ManyAppsRunning + "\t" + OneAppRunning
+ "\n";
> }
> }
> if (1 == numAppsRunning)
> {
> my.result.title =
> system.localizedStringWithFormat('TITLE_RUNNING_SINGULAR').replace(/
> \^0/gi,OneAppRunning);
> my.result.message =
> system.localizedStringWithFormat('ERROR_RUNNING');
> my.result.type = 'Fatal';
> return false;
> }
> if (1 < numAppsRunning)
> {
> my.result.title =
> system.localizedStringWithFormat('TITLE_RUNNING_PLURAL');
> my.result.message = ManyAppsRunning + "\n" +
> system.localizedStringWithFormat('ERROR_RUNNING');
> my.result.type = 'Fatal';
> return false;
> }
And here's the localizable strings:
> "TITLE_RUNNING_SINGULAR" = "Please quit ^0 before installing iLife.";
> "TITLE_RUNNING_PLURAL" = "Please quit the following programs before
> installing iLife:";
> "ERROR_RUNNING" = "The installer cannot update programs that are
> running.";
> "APPNAME_IPHOTO" = "iPhoto";
> "APPNAME_IMOVIE" = "iMovie";
> "APPNAME_IMOVIEHD" = "iMovie HD";
> "APPNAME_IDVD" = "iDVD";
> "APPNAME_GB" = "GarageBand";
> "APPNAME_iWeb" = "iWeb";
As you can see, if there's a single app that needs quitting, the user
sees:
> Please quit iMovie before installing iLife.
> The installer cannot update programs that are running.
If they have multiple, they see:
> Please quit the following programs before installing iLife:
> iMovie
> iWeb
> The installer cannot update programs that are running.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
etheanworld.com
This email sent to email@hidden
Promethean Limited is a company registered in England and Wales with company number 1308938 and VAT number GB 572 2599 18
______________________________________________
Promethean Ltd and or associated and or subsidiary companies :
The views expressed in this communication may not necessarily be
the views held by Promethean Ltd and or associated and or subsidiary companies.
This e-mail is for the exclusive use of the addressee(s). Unauthorised
disclosure, copying or distribution is prohibited.
This e-mail message has been swept for the presence of computer viruses.
Promethean Ltd and or associated and or subsidiary companies accepts no liability for any loss resulting from this email transmission.
Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 5TH, UK. Please update your records accordingly. Thank you!
*****************************************************************
This email has been checked by the e-Sweeper Service
*****************************************************************
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden