Archive: Installation type depending on file existing


Installation type depending on file existing
I am a bit of a newbie to nsis so plesae bear with me if this seems a little confusing.

I want to look to see if the .jar file we are installing already exists in teh install directory, if it doesnt I would just like to procede to the next page, but if it exists then I would like to have a dialog with 3 radio buttons as options appear. These 3 options would be "upgrade current version" which would overwrite the .jar but not the data. Option 2 wuold be "Clean Install" which would overwrite both the .jar and the data files. The third option would be "Install new in new location" which would just redirect the person back to the current page, where they could choose another directory location.

I know how to use the overwrite on/off and have a basic script working but I need to get this functionality into the script. Is this possible with a messsage box or do I need to create a custom page. Either way any hints or code examples would be greatly appreciated.

Thanks in advance,

Mike


i guess you know how to check for the file?
(IfFileExists jump_true jump_false)

then if you really want to have exactly those 3 options, you need indeed a custom page.

i'm too tired now to code it, but maybe tomorrow i can post some code.

in the meanwhile, you could browse the forums/wiki/documentation files about installtoptions :)


an example to help you as a starting point
an example to help you as a starting point :)


Thanks Red Wine,

It has got me started but I am still unsure how to accomplish what I am trying to do. I want the welcome page to appear, then the Directory page and then if the .jar file exists in the directory the user specified then they choose one of the options and the script installs the appropiate files, if the file doesnt exist I want it to skip the page with options and just do a clean install.

I am wondering at what point is the SEC01 called in nsis? Is it called when the instfiles page is called? I am trying to figure out exactly how everything ties together and works, I have a basic script working but I am not sure what the proper order/priority the code is executed.

As I mentioned I am I newbie at this so thank you for your understanding.

Mike


all sections are executed in the instfiles page, yes.


assuming sec01 is your first section, it is run when the install occurs. so yes it is what is called during your instfiles page. other install sections are also called here if you have them defined.

to do what you want, you could define the .onInit function (if you haven't already) which is an initialization callback run before any pages are displayed. in this function you could check for the existence of the .jar file and setup your custom page if so.


Function .onInit

IfFileExists "blah.jar" exists notexists

exists:
StrCpy $JarExists 1
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "myPage.ini"

notexists:

FunctionEnd


then you would have function that setup your custom page like this. note that abort in a page initialization function context does not abort the installation but only the creation of that page.


Function preInitMyPage
${If} $JarExists == 0
Abort
${EndIf}

// setup your custom page here
FunctionEnd


you'll also need to validate the response from your page with another function like this


Function validateMyPage
// get the user response here
FunctionEnd


note that using {If} requires that you include LogicLib.nsh in your project. also using the modern ui (MUI) makes custom pages a lot easier.

Originally posted by MikeInVancouver
Thanks Red Wine,

It has got me started but I am still unsure how to accomplish what I am trying to do. I want the welcome page to appear, then the Directory page and then if the .jar file exists in the directory the user specified then they choose one of the options and the script installs the appropiate files, if the file doesnt exist I want it to skip the page with options and just do a clean install.

I am wondering at what point is the SEC01 called in nsis? Is it called when the instfiles page is called? I am trying to figure out exactly how everything ties together and works, I have a basic script working but I am not sure what the proper order/priority the code is executed.

As I mentioned I am I newbie at this so thank you for your understanding.

Mike
Hi Mike,
provided example checks for an installation instead of asking users to point the installation folder. Assumes that the installer knows where/how to search in order to determine the existence of an installation on the target. It's based more or less on the installation structure that you mentioned on your 1st post on the top of this thread. Pages' order could be changed. Sections executed within instfiles page.
Now, the following attached example shows more or less the changed structure.

Thank you everyone,

With your help and reading all the documentation I could find I was able to accomplish what I set out to do. I really appreciate all the informative, and helpful feedback.

Mike