How do you make an update installer with NSIS? - installation

I currently have a project with an installer I made with NSIS, but I would like to have an update to new versions that only has the changed files and will show a changelog. The target platform is windows. What methods/suggestions do you have to do this?

You might want to reconsider using NSIS. If you are into patching and distributing updates you will probably get the most benefit from using an installer technology that utilises the Windows Installer capabilities (msiexec).
NSIS is basically a program that runs and does what you want whereas a Windows Installer type installer forces you to split your application into features and components which can be managed by the windows installer msi service. MSI will track things like what versions of products you have installed, whether running the installer again will run in maintenance mode, whether you are allowed to install 2 products of different versions, whether a patch can be applied to a particular version of a product or any other question relating to updates and installs.
Basically most of the stuff you are requesting will be available out-of-the-box if you change to a Windows Installer technology. Whereas if you use NSIS (which doesn't use Windows Installer technology) then you will have to implement it all yourself.
Just as an example there is a pretty comprehensive installer builder called AdvancedInstaller ( http://www.advancedinstaller.com/ ) that sounds like what you want.
Alternatively, if you want to spend the rest of your life trawling forums and newsgroups then there is an open source product called WiX that does something similar ;)

In spite of my previous comment I have written a 5000 line installer using NSIS with 13 custom pages. I have even looked at patching and it's a bit of a hack. The main bit of advice is to make sure you are patching the version you think you are patching then use one of the patching plugins available.
There are several patching technologies that compare files and produce patch change files and the NSIS code required to "install" them. I have found that NSIS Patch Gen did what I wanted pretty well with the least amount of hassle. The documentation is a bit thin but once you figure it out you think "Oh yeh".
You are probably going to have a little bit of trouble with an automatically generated Change Log. I would suggest that you create the Change Log yourself (or at least add the extra changes to it with each application change you make) and just include it as if it was a normal application file and let the patch generator update it.
http://sourceforge.net/projects/nsispatchgen/

One possible way would be to store an XML file on your download server that has each released version and a list of files that changed for each release. The installer would write a registry key on install of the version of files it installed.
Then, on update, the installer downloads and parses the XML file, and finds any nodes that have higher version numbers than what is currently installed. You display all the files in a text box on an installer page, and when the user confirms, the installer downloads all the files, and then updates the registry to the latest version.

are you familiar with cURL?
http://www.shininglightpro.com/products/Win32OpenSSL.html
http://curl.haxx.se/download.html#openssl
it will download any protocol, and you can use it to download your files. it's a commandline app.
in the installer, schedule a program which should check first to see if the main program is running or not and quit if it is running if not, calls curl to download a batch file from your site with the updates, then runs the batch file.
the batch file it downloads updates the app by downloading the correct files using curl.
the process should run maybe every 2 weeks or once a month, depending on how often you update.
the uninstall part of the installer should be capable of removing all parts of the app in question,including any updates. this can be accomplished by removing all files from that subdir of program files.
RMDir /r /REBOOTOK '$INSTDIR'
RMDir /r /REBOOTOK "$SMPROGRAMS\$StartMenuFolder"
Delete '$SMPROGRAMS\$StartMenuFolder\gpl3license.lnk'
Delete '$SMPROGRAMS\$StartMenuFolder\readme.lnk'
Delete '$SMPROGRAMS\$StartMenuFolder\${PRODUCT_TITLE}.lnk'
DeleteRegKey HKCU "Software\Your major subkey\${PRODUCT_NAME}"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
DeleteRegKey /ifempty HKCU "Software\${PRODUCT_NAME}"
PRODUCT_NAME is a !define I made because I use these nsi files like a template.
this is only a piece of the installer file's uninstaller section.

I've been able to create a patch updater program for my Windows app (a CLI which uses NSIS as its installer) by releasing the app to my personal CDN (or some hosting platform) and taking advantage of Node.js modules like path to replace the binary (using a similar procedure to equinox.io) with a given version from the CDN and winreg to update the Windows Registry accordingly. Since I've namespaced my Windows Registry key, the uninstaller still works for it.
If anyone wants more details on this, please ask. I'm happy to help.

Some compilers like Delphi make a lot of changes in the final executable even if you change a little part of your code.
So first you should see if it worth patching.
Another consideration is patching by itself.
Patching maybe blocked by some Anti Virus Software specially in some system folders.
and finally incremental patching data size can grow beyond the original files.
Based on above subjects I don't suggest you patching.
Use full installers instead

Related

Why app installed using MSI installer would disappear from Windows

We made some changes to the installation and updating process of our Windows app recently, and some users are now complaining that Windows sometimes automatically deletes the main application .exe file.
It usually occurs after users update app using built-in web update feature. The feature is implemented using .msi built in Advanced Installer tool.
We are struggling to figure out what is causing this, and haven't found a way to consistently reproduce the issue (though we've seen it happen as well).
Here's what changed with our installation and web updating process:
The main installer for our application is now a standard .msi, which becomes a part of the Windows installation system and is natively manageable by Group Policy and other system features, such as rollback or versions. In previous versions that did not have this problem, our installer was a .exe built with the SetupBuilder tool.
We introduced the redesigned web updater feature inside the app (to update to new versions within the app). It uses the same .msi as the main deliverable as for installation. .msi is downloaded from our server in a form of .exe which is then extracts MSI and starts it. MSI then updates file in our installation. These .exe and .msi is built with Advanced Installer tool which provides such a web update feature to developers. In previous versions that did not have this problem, our web update feature was developed with SetupBuilder tool which provided a custom web update files - .exe web updater that downloads a number of web update files containing patch to our app.
The goal of a transition to the standard .msi installer was to make it easy for our clients to deploy the app in organizations - say, mass deploy using group policies and other similar tools.
Has anyone else experienced a problem like this? Any ideas on how to troubleshoot and try to reproduce?
Theory: Before doing anything else: The first thing I would ask the people who report the problem is if they have re-packaged your older, legacy (non-MSI) setup to be their own MSI file? This can cause a well-known upgrade problem along the lines of what you explain (file missing). Please check first. Tell them to uninstall the existing version and then install the new one - that is the simplest way. Not always enough (some obscure problems possible).
Mismatched component GUIDs could cause missing files after upgrade, as could file version downgrade scenarios and various other technicalities. You could try to install to a new default location on disk to avoid these problems. The reason this can work is very technical and hard to explain tersely. Essentially you de-couple yourself from "the sins of the past". It is generally enough to change the name of the file in question: for example MyApp.exe to MyAppNew.exe or maybe add the major version: MyApp5.exe, but maybe try the folder change first ProgramFiles\MyCompany\MyApp => ProgramFiles\MyCompany\MyApp5.
How do you configure your upgrade? View "Upgrades", what is selected: "Uninstall old version first and then install new version" or "Install new version first and then uninstall old version".
Blog Entry:: Why Windows Installer removes files during a major upgrade if they go backwards in version numbers (might be of help).
Deployment Debugging: For open ended debugging of MSI and deployment problems in general one obviously needs to gather intel and that means logging and system inspection.
Logging: First try to get a proper log file for the systems where this problem occurs. In Advanced Installer you can tick the "Enable verbose logging" in the Install Parameters view to enable verbose logging for all package installations. This adds the MsiLogging property to the compiled MSI and every installation of the MSI will cause a MSI log file with a random name to be created in the TMP folder. View the folder, sort by date and the file should be at the top. Suggest you do this and then tell the users to send you the log files when relevant. Maybe you have this setting enabled already?
Further Logging: There are many ways to enable logging, and you can find a description here: Enable installation logs for MSI installer without any command line arguments. The MsiLogging property is just one possibility.
To log a single MSI setup: http://www.installsite.org/pages/en/msifaq/a/1022.htm.
To enable global logging for all MSI operations on the machine: Please see this FAQ-entry from installsite.org, section "Globally for all setups on a machine" - for the exact procedure.
How to interpret an MSI Log File.

.ini file not being modified/updated when doing an upgrade with installshield since some folders are not being deleted when upgrading

Not too long ago I got a new job working on a tool that the company created to make people's lives easier when working on AWR.
I have successfully done multiple fixes and improvements which I was able to distribute via HotFix installers (simply overwrite the files that are already there).
My latest change/addition to the tool requires I create a complete installer for the tool. This particular tool always installs 2 versions, the current/new and the previous/old, to give a smoother transition to users. I have never done an installer before so I am learning as I go.
I was able to create an installer using the previous installshield project by simply updating/adding/removing files and folders. This works great when there is no version of the tool installed on the computer and there are no files/folders of any version of it on the installation locations.
I looked online and found that to make an installer that will install over a previous version I would need to do a major upgrade with installshield, which I did do after reading that. Now the installer successfully installs over the old version, it successfully places the new files and folders on their locations but always leaves one particular empty folder behind, the one for the 1.1.1 version.
That didn't seem like a problem until I realized that the .exe failed to modify the .ini file that it needs to modify to let AWR know where to look for the scripts. I looked through the .exe code and after running some tests, running it alone, I realized the .exe is not the problem, it does the job correctly. After doing many tests I found that as long as those empty folders exist the .ini files cannot be modified. I have no clue why since the .ini file is pretty much a .txt file and it makes no sense for there to be some sort of dependency on the 1.1.1 folder.
So my problem is one of two, either I have to figure out a way to make sure that the upgrade deletes those 1.1.1 folders or find a way to modify the .ini files with those folders still there. I have looked online and every solution requires me/the user to manually do something and I am being asked to make the installer simply work when used. They are asking me to make it so the installer takes care of everything and the user should not do anything except run the installer.
Since the installer works correctly as long as those folders are not there I figured making sure the installer removes them is the best way but I am stuck and I do not know how to proceed.
Thank you for any advice and help you can provide with this issue.
Solution:
Deleted all files I needed to make sure were updated from the components list and re-added them to the installshield project.
Since doing that everything was updated correctly and the folders were removed since the .exe was the correct one.

InstallShield Custom Action failing because user installing in 64-bit Program Files directory?

I have a 32-bit legacy application that allows users to specify the install path as part of the setup (pretty normal stuff...). I also have a custom action defined that runs a silent background install of another required bit of software after the initial installation is complete.
All is well when users install to the 32-bit Program Files (x86) directory.
Where I am running into problems is when users specify the 64-bit installation directory, Windows automagically changes the install path in the background to use the (x86) Program Files folder, which is fine, except that my custom actions that use the same INSTALLDIR property after the initial install is finished still think that it should be the 64-bit "Program Files" path - so the install fails when the custom action can't find the EXE file it's looking for.
My program is essentially exactly the same as the one described here by another developer but never resolved in that forum: http://community.flexerasoftware.com/archive/index.php?t-216268.html
Does anyone have a clue what a valid workaround for this is? It seems pretty basic that an installer should not fail just because users think they should install to "C:\Program Files\Appname" instead of "C:\Program Files (x86)\AppName".
I did peruse the similar questions on here but I don't see anyone else with this issue using custom actions.
In my experience you need to change to a 64 bit template to install to program files. General information in the tree > Template summary > change to x64;1033. At least one file needs to be marked as 64 bit in each directory. It is a check box on the component property. Be sure to check your custom actions still obey run conditions on major upgrades. I am having issues with that currently. Major upgrades on mine is set to remove all and it runs all custom actions no matter the conditions on the removal portion of the script.

Windows installer is too clever, tries to repair when tester deletes config file

Our application is deployed to the target machine with an msi file. All works nicely. Our tester has gone through his plan, and one of the tests requires deleting the application's configuration file. The application is designed to alert the user with a dialog on startup saying "missing config". However, what happens is that - somehow! - the software starts the installer again and retrieves the missing file from the msi! Which is nice, but not what we want. How do we disable that behaviour?
without going into much depth of the windows installer mechanics (if you interested in that there a plenty of articles about this), the shortcut of the software is probably advertised, which means the windows installer checks if everything is in its place before the software is started.
if you can edit the msi, make the shortcut non advertised.
if you can't, install it with DISABLEADVTSHORTCUTS
e.g. msiexec /i myMsi.msi DISABLEADVTSHORTCUTS=1
please note that this is only a quick (and dirty) workaround,
to fix this proper you need to understand the whole windows installer advertising (also called repair or self resiliency) mechanism.
but explaining all the causes and the mechanism of the repair is far beyond this answer and there are quite some articles and posts about that on the internet (and especially on MSDN and stackoverflow)
There is a more correct answer to this, and it is NOT DISABLEADVTSHORTCUTS. You set the component id to null in the MSI file to prevent repair of that individual file. See ComponentId comments here:
http://msdn.microsoft.com/en-us/library/aa368007(v=vs.85).aspx
Edit the MSI file with Orca to delete the Componenty ID, and write an uninstall custom action to delete the file at uninstall if it's there.
In addition, that's a redundant test. Windows will restore that file for you if it's missing, so the idea that you need a test to notify that it's missing is pointless. The true test should be that Windows will restore the file if it's lost, and your app needs to do potentially nothing about the missing file.
You don't mention what tool you are using to make your MSI but I'm going to go out on a limb and guess Visual Studio Deployment Projects (.VDRPOJ).
One of the (many) horrible things about this tool was that it fails to expose the foundational concept of components. Instead it makes every file a key file of it's own component and hides the existence of the component from you. I say 'was' because Microsoft killed this project type in VS. There are around 50k people complaining on UserVoice to bring this tool back and I'm guessing that 49,990 of them don't know what a key path is.
Windows Installer has a concept called the component rules and each component has a keypath. The keypath teaches MSI how to handle repair scenarios. But your tool has to allow you to be able to control this to make it work.
Windows Installer is functioning exactly the way it's supposed to function. You just aren't up to speed on what that is.
However, if you want to ignore Windows Installer best practices and continue using the tool you use today, the trick is to install the app.config file as a different file. Then have the application copy the file to the real file name on run. Windows Installer won't service what it didn't install.
Several answers have been provided that can work:
You can install the file with a blank guid. Then you need to remove it on uninstall using the RemoveFile feature. You will also run into issues if you want to replace it during an upgrade. Could be tricky at times.
You can disable the advertised shortcut(s), but this affects too much in my opinion.
Finally you can use my suggestion to install a separate non-advertised shortcut to use to launch the application. Such a shortcut bypasses the self-repair check. It may still be invoked by other means such as missing file associations, COM registration or similar, but those are exception states.
However, my preference is that an application can start without a config file present, if at all possible. I always suggest a good startup routine with "internal defaults" available. The startup routine should also degrade gracefully if faced with any file system access denied conditions.
Most importantly you should place this config file in the userprofile so you can generate the file on first launch for the user in question. It can even be copied from a read-only copy in the main installation directory.
When you generate a file from internal defaults and put it in a userprofile location, the file will have no interference with Windows Installer at all. The issues that results is how to clean up user data on uninstall. I discussed this with Stefan Kruger (MSI MVP) at one point, and I agree with his notion that user data is indeed user data and should not be automatically dealt with by your installer at all. Leave it installed, and clean it up via system administrator tools if necessary - for example logon scripts.

Capturing all changes during an application install on Windows

I need to monitor and report on all changes (folders and directories added, permissions changed, registry entries added) that are made during the installation of a software program. Can anyone suggest a tool that is capable of doing this?
Thanks, MagicAndi.
Note: Please see my other answer below as well.
Seeing as you want to create a Wix setup, I want to add a new answer with some hints on how to accomplish this in the quickest way.
I would recommend using the InstallRite (no longer available) software to get a log of changes done by the installer you got. This tool does not allow you to convert the capture into an MSI, but it gives you a good change log (which does contain a bit of junk). The PictureTaker tool appears to have been renamed and is now commercial - it does allow conversion of the capture to MSI though.
There seems to be a new capture tool called Scalable Smart Packager CE (link removed Nov, 2017 - target site has changed and looks a little suspicious). I have not tested this tool thoroughly.
Once you have your log or capture, you can convert to WIX in 2 "fast track" ways:
Use the dark.exe WIX MSI decompiler (if you have an MSI already)
Use the heat.exe WIX harvester tool (to auto-generate WIX XML for folders, registry etc..)
If you use the dark.exe tool you should get a complete WIX XML file that you can then compile again - but you should clean it up a bit (take out the UI junk, then link with WIX's detault built-in GUI etc...).
Using heat.exe is the cleaner way. You simply run the heat.exe tool against a folder, and it will create WIX XML elements for you to install those files. You will then need to put it all together in a WIX source files along with other required sections. I can provide you with a basic WIX "minimal sample" to get you going (I don't seem to be able to attach files here).
Looks like this is a duplicate of a question answered already on ServerFault (my bad!). The answers given there are:
Process Monitor from SysInternals Software
Total Uninstall from Martau.com
UPDATE: Stefan Kruger's comprehensive list of repackaging tools at installsite.org.
Your question is a bit open ended since it is not entirely clear what the overall goal is:
Application Repackaging: capture all changes and then package them into a deployable package format such as MSI (or similar).
Reporting / Monitoring: just looking for a way to "see what happens" during an installation.
For application repackaging the main tool is AdminStudio (the main competitor "Wise InstallStudio" was pulled from market due to legal issues, see Wise section here: What installation product to use? InstallShield, WiX, Wise, Advanced Installer, etc).
AdminStudio has very comprehensive feature sets and a hefty price tag (and learning curve). You could try to use the trial version to do your repackaging and see if the resulting MSI is useable. If it is not you can convert it to a Wix MSI relatively easily via the dark.exe Wix tool.
Then there used to be more light weight tools such as PictureTaker and InstallRite which I suppose were better suited for "reporting purposes" but could be used for MSI creation. Both these tools seem to have disappeared as well.
There seems to be a new capture tool called Scalable Smart Packager CE (removed broken link Jan, 2018 - the tool appears discontinued). I have not tested this tool thoroughly.
UPDATE: I just removed a broken link to Scalable Smart Packager CE (appears discontinued). For repackaging software / tools, perhaps see Stefan Kruger's comprehensive list at installsite.org. Hard to keep up with all these tools that are useful but end up deprecated.
You could use the method suggested here: Tracking file and registry changes, or you can try to locate the old version of WININSTALL LE on a Windows 2000 Server CD in \VALUEADD\3RDPARTY\MGMT\WINSTLE.
I believe Advanced Installer allows capture, but I am not sure you can export a proper MSI file with the trial version (or at all for that matter).
I've used Process Monitor on multiple occasions to document the impacts of installing COTS software on servers. Has always seemed to do the trick.
There is a programme called "sandboxie"
You'll need to configure it once its installed for it to work properly.
run sandboxie. drag and drop the installation file into the gui and watch it try to install.
Sandboxie creates a log of everything that happens. While it redirects all of the exe - DLL - inf - scripts and everything else into a quarantine file instead.
The SB GUI then lays out the file structure to all the intended installation locations.
Any download Im not too sure is legitimate, now gets downloaded and executed straight through SB's web browser feature. I can then check it all out and it never infects my system if it is naughty.
On the other hand...
If it was a online installer.exe that was executed in SB gui, youll now have a copy of everything that makes up the installer package. Place it all in a file on a USB, make a simple autorun.inf and .bat file with notepad++ to create ya own offline installer
Hope this helps...

Resources