NSIS Recursive Log File

Story

Hello to all,

Is there a way to recursively move a directory with NSIS at compile time?

thanks


Long story

Hello to all,

I am trying to create an installer with NSIS for the software that I am developing. The build system we created creates a folder with everything you need to run this software on Windows (dll, exes, images, libraries, examples, etc.). There are +400 files and folders in this folder. Using HM NIS Edit, it was possible to create the “File” and “SetOutPath” sequences needed to set all the content, but just huge, ugly, and if some files were added or deleted, we had to change the script manually.

So ... we removed the generated sequence "File" and "SetOutPath" and simply added:

File /r "C:\path\to\output\dir" 

It works fine ... but now we have a problem with the uninstaller, because we can not do this:

 RMDir /r $INSTDIR 

Because it is dangerous (as indicated here: http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.1.8 ).

So, we tried to follow the recommendation there: http://nsis.sourceforge.net/Uninstall_only_installed_files

This solution creates a log in which NSIS records all completed File and SetOutPath operations so that it can back out (delete) when it is deleted. The problem is that the included macros do not support the recursive "File" option.

I tried to implement a recursive version by recursively walking around a folder, but I think I'm doing it wrong (well, I'm sure: P):

 !include "RecFind.nsh" Section "Principal" SEC01 ${SetOutPath} "$INSTDIR" SetOverwrite try ${RecFindOpen} "..\executable" $R0 $R1 DetailPrint "Looking into directory: $R0" ${SetOutPath} "$R0" ${RecFindFirst} DetailPrint "Looking file: $R0\$R1" ${File} "$R0" "$R1" ${RecFindNext} ${RecFindClose} 

Using this http://nsis.sourceforge.net/RecFind:_Recursive_FindFirst,_FindNext,_FindClose But I think it only works during installation.

The solution I have found so far is to create a script installer with the NSIS file used as the template (with some placeholder token for the File and SetOutPath lists), a Python script that goes through the output directory and creates the sequence " File "and" SetOutPath "and then writes the final NSIS script ... but I really don't like it: S

So my question is:

Is there a way to recursively move a directory with NSIS at compile time?

(Or, how can I achieve this only with NSIS?).

Thanks in advance.

Yours faithfully

+4
source share
2 answers
 !ifdef GENFILELIST outfile "${GENFILELIST}.exe" requestexecutionlevel user silentinstall silent Var ins Var uns Function ProcessDir Pop $R1 ;reldir Pop $R0 ;absdir Push $0 Push $1 FileWrite $ins 'Push $$Outdir$\n' FileWrite $ins 'SetOutPath "$$instdir\$R1"$\n' FindFirst $0 $1 "$R0\*" loop: StrCmp "" $1 done StrCmp "." $1 next StrCmp ".." $1 next IfFileExists "$R0\$1\*.*" 0 processfile Push $R0 Push $R1 Push "$R0\$1" Push "$R1$1\" call ProcessDir Pop $R1 Pop $R0 goto next processfile: FileWrite $ins 'File "${SRCDIR}\$R1$1"$\n' FileWrite $uns 'Delete "$$instdir\$R1$1"$\n' next: FindNext $0 $1 Goto loop done: FindClose $0 FileWrite $uns 'RMDir "$$instdir\$R1"$\n' FileWrite $ins 'Pop $$Outdir$\n' Pop $1 Pop $0 FunctionEnd section FileOpen $ins "${GENFILELIST}ins" w FileOpen $uns "${GENFILELIST}uns" w Push "${SRCDIR}" Push "" call ProcessDir sectionend !else !tempfile FILELIST !system '"${NSISDIR}\makensis" -NOCD "-DGENFILELIST=${FILELIST}" "-DSRCDIR=.\myfiles" "${__FILE__}"' = 0 !system '"${FILELIST}.exe"' = 0 !delfile "${FILELIST}" !delfile "${FILELIST}.exe" ### Main script starts here ### outfile test.exe page directory page instfiles section SetOutPath $instdir WriteUninstaller "$instdir\uninst.exe" !include "${FILELIST}ins" !delfile "${FILELIST}ins" sectionend section uninstall !include "${FILELIST}uns" !delfile "${FILELIST}uns" Delete "$instdir\uninst.exe" RMDir "$instdir" sectionend !endif 

This system uses to create a silent installer, and when this silent installer is executed, it generates text files with the commands "File" and "Delete", a real installer script! enables them to execute install and uninstall commands.

You can use! a system for executing something, a batch file, a host of Windows scripts, python, etc.

+3
source

You were on the right track.

Use this set of scripts.

http://nsis.sourceforge.net/Advanced_Uninstall_Log_NSIS_Header

It allows you to use the recursive functionality of the File function and makes an uninstallation log for you.

0
source

Source: https://habr.com/ru/post/1385202/


All Articles