Backup/restore
I would like the installer to backup some folders and files in them, put them in a preselected folder...
And the uninstaller should ask the user if he wants to restore the backup.
Is that possible?
Archive: Backup/restore
Backup/restore
I would like the installer to backup some folders and files in them, put them in a preselected folder...
And the uninstaller should ask the user if he wants to restore the backup.
Is that possible?
Yes it is.
The easiest thing would be to have a MessageBox asking the user if he/she wants to copy the installed files to a Backup folder.
Then on Uninstall, check if a Backup folder exists, and if one does, ask the user again if he wants to copy the Backup back after uninstallation.
Also, on installation, you should check that no Backup folder already exists, and if one does, ask the user if he/she wants to remove it before the new backup copying occurs.
-Stu
Yes, that's exactly what I want to do...
But the problem is I'm still a beginner and don't know how to do it...
Can someone help?
Ok, for a start...
Function DoBackup
## First, check for previous installation
IfFileExists "$INSTDIR\*.*" 0 NoBackup
MessageBox MB_YESNO|MB_ICONQUESTION "A previous installation of [product name] was found.$\r$\n$\r$\nWould you like to create a backup?" IDNO NoBackup
## Check for previous backup too!!!
IfFileExists "$INSTDIR\Backup\*.*" 0 +2
MessageBox MB_OKCANCEL|MB_ICONINFORMATION "A previous backup was found!$\r$\n$\r$\nWould you like to remove the previous backup?" IDCANCEL Error
RMDir /r "$INSTDIR\Backup"
##Do the backup [we will move all to Temp Plugins folder]
InitPluginsDir
Rename "$INSTDIR" "$PLUGINSDIR\Backup"
CreateDirectory "$INSTDIR" #make $INSTDIR
Rename "$PLUGINSDIR\Backup" "$INSTDIR\Backup" #move to new backup
MessageBox MB_OK|MB_ICONINFORMATION "Backup completed.$\r$\n$\r$\nInstallation will now continue" IDOK NoBackup
Error:
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "You have chosen not to remove the previous backup, therefore a new backup cannot take place.$\r$\nClick OK to continue with the installation." IDOK NoBackup
Abort
NoBackup:
FunctionEnd
It doesn't work...
Says:
1 warning:
install function "DoBackup" not referenced - zeroing code (0-14) out.
???
You need to call the function with "Call DoBackup"
-Stu
Sorry for asking this but I'm a beginner...
How do I call the function?
Do I need to put the code you gave me in my script or in a seperate file and then call it with the .nsi script?
Put the Function in your script.
Like I have said, use:
Call DoBackup in a Section or Function.
Optionally, change the name of the Function to .onInit and it will be called as the installer starts.
Although, if you're using MUI, I recommend you call it as a leave function for the Welcome page.
See MUI readme about setting Custom Functions.
-Stu