- Details
- Written by: INsane
- Category: NSIS Installers
- Hits: 5859


Sometimes you may want to make an installer that overwrites files that the user may not want deleted or overwritten. You can back up these files on the users folders... and then when the user uninstalls your content, the uninstaller will return (restore) the users files and folders to their previous state.
To do this is not hard, but it does mean a fair bit of effort on installs that have a lot of files.
Basically you have to use two Macros as described in this wiki by "Afrow UK" (see"Usage").
I made a special HUD recently, its use was for making movies on-line using Fraps or other programs like Fraps that make an AVI while you play the game. The HUD removes all items of the HUD and weapons, sleeves and hands in the first person view.
The problem is that if this was a normal install that wrote over the user's files in the game directory, it would wipe put all custom files.
So using these two macros it was possible for the user to install this hud and replace ANY files the HUD needed to run in this "No HUD" mode, then return the users custom files like weapons, player models, custom hud... no matter what files were installed... they return after uninstall.
If you have read and understood the macros article and how it works and you have advanced enough to edit the NSIS script, then you should be able to use these macros. How I approached this problem was like this...
* Start out by making a NSIS installer in the normal manner.
Read the previous Tutorials on that, if you have not, visit here.
* Read and understand how the macros work. There is one line...
!insertmacro BackupFile "Dir with file in it" "File" "Backup to"
...to insert in the Section parts of the script, normally this is where the instructions and addresses of the files to be installed are kept...
![]() |
There is another line...
!insertmacro RestoreFile "Backup dir with file in it" "File" "Restore to"
...to insert in the Section Uninstall parts of the script, take care where you place the macros, layout is important. Try to do it in an order as if you were doing the same work in the folder manually.
![]() |
* You will have to install the macros, somewhere at the top of the script is fine...
![]() |
This takes a bit of time to get your head around but if you master this you will be able to make all sorts of installers.
If I have failed to explain this properly or there is something you just don't get maybe you would like to examine two scripts.
Script no 1. This is the script that built the "NO HUD" installer before I put the backup macros in. It was just a standard script with the "Steam folder finder for dod source...." in it.
Script no 2. This is the same script after I put the backup macros in.
Notice the changes I had to make, copy and paste the "Script no 2" into HM NIS Edit and look at lines...
Designed by INsane Webmaster - dodbits.com using Template Toaster (Joomla! Version 4)