Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

ComponentReinstall()


3 replies to this topic

Robin

Robin
  • Members
  • 5 posts

Posted 30 May 2002 - 13:28

Not sure if I'm just missing something here, but most of the different ways one can avoid maintenance mode (including  the one outlined in the KB here) seem to have one thing in common - they don't really do what they purport to! Disregarding the UI etc, ultimately what they do when a setup is run a second time is use ComponentReinstall(). The problem with that being that if your setup is a newer version and it's being installed over the top of the older one it will simply reinstall all the old files, not the new ones... :o\

For the installer I'm doing now, rerunning it will be quite common (selecting different components etc), which is bad enough because if you deselect anything that you installed before, it will be removed! (but I have some ideas for avoiding that scenario).
The big problem is that I want to use the same installer for regular new versions of the application, but I don't want to change the GUID each time (resulting in multiple add\remove entries). My current setup would be fine except it always reinstalls the original versions of files even when I've rebuilt with new ones.

Anyone got any suggestions?  Currently I'm using a slightly modified version of the aforementioned solution, is there an alternative to ComponentReinstall() at the point of moving files on a second run through? Basically OnMaintUIBefore() contains all the same dialogs etc as OnFirstUIBefore(), but OnMaintUIBefore() just calls ComponentReinstall() at the end.



Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 30 May 2002 - 18:37

Ohh, I definitely don't like that solution.  It asks you to pretty much duplicate all of your OnFirstUIBefore and OnFirstUIAfter code.  Yuck!

I have dealt with this problem first hand, so I know what you're going though.  I would suggest reverting back to a program-driven model like in IS5.  The code would basically goes as follows:

Code Sample

program
 if (CMDLINE % UNINSTALL_CMD) then
    Uninstall()
 else
    Install()
endif;

function Uninstall()
NUMBER nResult;
begin
 nResult = AskYesNo ("This will remove "+UNINSTALL_NAME+" from your computer. Do you wish to proceed?", NO);
 if ( nResult = YES ) then
   ComponentRemoveAll();
   nResult = ComponentTransferData(MEDIA);
   HandleComponentError(nResult);
 endif;
end;

function Install()
begin
 OnBegin();

 //szBitmapName = SUPPORTDIR ^ "FILENAME.BMP";
 //PlaceBitmap(szBitmapName, 1001, 10, 12, UPPER_LEFT);  
 PlaceWindow(BILLBOARD, 30, 30, LOWER_RIGHT);

 OnFirstUIBeforeN();

 // FORCE A REINSTALL OF THE COMPONENTS
 nResult = ComponentReinstall();
 nResult = ComponentTransferData(MEDIA);
 HandleComponentError(nResult);

 // OVERWRITE DEFAULT UNINSTALL ENTRY
 Debug("DEBUG: ARP Information ... \n"+
       " - Key = '"+UNINSTALL_KEY+"'\n"+
       " - Value = '"+UNINSTALL_VALUE+"'\n", INFORMATION);
 RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);  
 nvType =  REGDB_STRING;
 RegDBSetKeyValueEx(UNINSTALL_KEY, "UninstallString", nvType, UNINSTALL_VALUE, -1);
 RegDBSetKeyValueEx(UNINSTALL_KEY, "DisplayIcon", nvType, TARGETDIR ^ "\\BIN\\pb.exe", -1);

 // --THE END--  
 szTitle = "Setup Complete";
 szMsg = "The setup is complete. \n\n" +
         "Thank you for choosing "+@PRODUCT_NAME+".";
 if (bReboot) then
   SdFinishReboot(szTitle, szMsg, SYS_BOOTMACHINE, "", 0);
 else
   SdFinish(szTitle, szMsg, "", "", "", bvOpt1, bvOpt2);
 endif;
end;


Also, there are several ways to handle the deselecting of components, but you're right--any unselected ones will be removed if necessary.  One way though is to either make an invisible ghost component which the required components are dependent on.  Another is to simply have your script force certain components to be checked/unchecked.  A third, which takes a lot more work, it to save off the components state and then re-apply them when the install is re-ran.  Unfortunately though there's no automatic way to do this, so like I said, it takes a lot of custom code.

Hope it helps.  If you have specific questions, you can try sending me a private msg. or simply respond to this post.
user posted image

Robin

Robin
  • Members
  • 5 posts

Posted 31 May 2002 - 10:33

That's a nice suggestion thanks. Wouldn't the Uninstall() function be better like this?:
Code Sample

function Uninstall()
NUMBER nResult;
STRING svResult, szCaption;
begin
svResult = SdLoadString(IFX_MAINTUI_MSG);
szCaption = SdLoadString(IFX_ONMAINTUI_CAPTION);
nResult = SprintfBox(MB_OKCANCEL,szCaption,"%s",svResult);
if (nResult = IDCANCEL) then
   abort;
elseif(nResult = IDOK) then
   ComponentRemoveAll();
   nResult = ComponentTransferData(MEDIA);
   HandleComponentError(nResult);
endif;  
end;

Anyway I think I'll go with your suggestion, it's much nicer than the horrible 'workaround' I'm using as per the KB article.

I've realised that I was wrong about ComponentReinstall(), hehe. I think my testing must have gone awry somewhere because it doesn't reinstall the original components (I thought it was a bit odd, since to do that it would have to store all the data in DISK1TARGET). I don't think I was firing on all cylinders yesterday :)
As you say, I still have to make sure that on a rerun all the components that were selected on the first run are selected again. I think I'll probably resort to searching the targetdir for giveaway files and then invisibly selecting the components I find just before the data move.

It would be nice if you could actually capture events in the dialogues, like having an OnChange() event for checkboxes etc. That would be invaluable.

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 01 June 2002 - 00:11

Yeah, that Uninstall of yours would certainly work too.  Same basic thing in the end.  Besides, I was just trying to convey the idea, not go for the end all, be all solution.  :)  Glad to hear like my suggestion though.

Also, ComponentReinstall() will reinstall the previously selected components should you make use of IS6's maintenance mode, but that is certainly not the case here.

Also, I agree it would be great if you could key off such OnChange type events, but unfortunately IS is not that powerful.  You're therefore left with either interegating the selected components, or as you said, looking for key files.  However, if you offer a custom setup option, which I'm assuming you do, you should load the previous selections before displaying that dialog and not do it just prior to the data move.
user posted image