NSIS: Setting a default $INSTDIR

n4gix

Resource contributor
#1
I was charged with creating an installer for the TC310R for X-Plane 11 yesterday. Since X-Plane 11 does not use the Registry to store any path information, I had to discover a way to at least set a default path for the installer to use. As it turns out this was far simpler than I thought it might actually be. :idea:

So for the benefit of anyone else faced with this issue, here is the solution:

Code:
Function .onInit
    InitPluginsDir
    StrCpy $INSTDIR "C:\X-Plane 11"
FunctionEnd
 

Heretic

Resource contributor
#2
I wouldn't set a default path as X-Plane tends to get installed anywhere.

Unless you've alsready done so, you should have the installer copy the aircraft's root folder into a subfolder in "Aircraft", e.g. X-Plane 11\Aircraft\Milviz\TC310R. It'll prevent cluttering up the "Aircraft" folder.
 

n4gix

Resource contributor
#3
That is precisely what the installer does. I just didn't want the user to have a totally empty "box" and a Browse button. If they should happen to ignore that and click on "Install" then all the files would be installed on the root OS drive, but not within the scope of X-Plane 11's folder!

The script below will automatically create any needed sub-folders as it processes the files. At the end, the installer will launch the aircraft's manual.

Code:
  ${If} $RadioButton1_State == 1
    SetOutPath "$INSTDIR\Aircraft\Milviz\Milviz T310R"
    File /r "D:\Dropbox\Milviz Team Folder\Installer Build Folder\C310R-XP\Aircraft\Milviz\Milviz T310R\*.*"
  ${EndIf}
 
  ${If} $RadioButton1_State == 1
        ExecShell open "$INSTDIR\Aircraft\Milviz\Milviz T310R\CT310R_XP_User_Guide.pdf"
  ${EndIf}
The uninstaller will simply remove the aircraft and all of it's files, leaving the ..\Milviz folder present so as not to affect any other Milviz aircraft that may be installed.
Code:
;  PUT UNINSTALLER SCRIPT HERE!
Section

${If} $Checkbox2_State == 1
  SetOutPath "$INSTDIR\Aircraft\Milviz\"
  RMDir /r "$INSTDIR\Aircraft\Milviz\Milviz T310R\*.*"
${EndIf}

SectionEnd
 

Heretic

Resource contributor
#4
I just didn't want the user to have a totally empty "box" and a Browse button.
But that's the most feasible solution!

If an inexperienced or absent-minded user has his/her XP11 folder on the desktop and your installer suggests "C:\X-Plane 11" by default, there is a risk of the user simply continuing the process, putting the aircraft folder into a totally unusable location and consequently triggering complaints about a non-showing add-on.

At least try to implement a check for any of XP's executable files and display a warning if it can't be found in the destination directory.

Also, what about Linux and iOS?


- Edit:

Just found out that "X-plane_install_11.txt" in "C:\Users\[username]\AppData\Local" contains all locations that X-Plane's installer was told to use for X-Plane's root folder, with the most recently used full directory path stated in the last line of the file.
 
Last edited:

n4gix

Resource contributor
#5
Odd that several hours of "Google-Fu" didn't yield that bit of information.

In any case it is now a moot issue. The 'boss' had forgotten about the possibility of Linux and/or iOS, so decided to scrap that installer completely. While I could build an installer for either of the above systems, it would be confusing maintaining three separate installers for a single project, especially given that none of the team members have or use Linux or iOS so we'd have no way to test 'em! :rotfl:
 
Last edited:

Heretic

Resource contributor
#6
Odd that several hours of "Google-Fu" didn't yield that bit of information.
Don't worry, I only stumbled across it in the XP forums by chance.

In any case it is now a moot issue. The 'boss' had forgotten about the possibility of Linux and/or iOS, so decided to scrap that installer completely. While I could build an installer for either of the above systems, it would be confusing maintaining three separate installers for a single project, especially given that none of the team members have or use Linux or iOS so we'd have to way to test 'em! :rotfl:
So what are you going to do instead? Password protected archives? And how are you performing license checks? SASL?

I have XP11 configured for use on Arch Linux, so I could do a bit of testing, time permitting.
 

n4gix

Resource contributor
#7
I've no idea. There is an entirely different team working on the X-Plane project(s). I was only tasked with creating an installer for them, until sanity prevailed when they realized that said installer wouldn't cover all three OS platforms.
 
Top