Skip to content
⌘ NSIS Forum Archive

extract files during install

12 posts

shekara#

extract files during install

i am using a File command to copy directory from source and destination. I cannot use a copy.
it works for now. but when if any file is locked, it fails. anyways to improve this
!macro ExtractDirectory dest source asterisk recursive
SetOverwrite on
${LogIt} "ExtractDirectory from: $\"${source}\${asterisk}$\" to $\"${dest}$\" recursive: $\"${recursive}$\""
#RMDir /r ${dest}
SetOutPath ${dest}
ClearErrors
${If} ${recursive} == "true"
File /r `${source}\${asterisk}`
${Else}
File `${source}\${asterisk}`
${EndIf}
${If} ${Errors}
${LogReportAbort} "ExtractDirectory: from: ${source} failed..." "ExtractDirectory: from: ${source} failed..."
${EndIf}
!macroend
shekara#
I am not able to identify that. I am extracting 2 directories and in between my install fails with onInstFailed action. I can see in logs first one is completed and prior to starting of the second one, I see installation fail or aborted message.
Anders#
If it does not fail in makensis then it is not the source.


This will display a dialog when not running in silent mode:
Section
InitPluginsDir
FileOpen $1 "$PluginsDir\test.txt" w ; Lock file
ExecShell  "" "cmd.exe" '/C ping -n 99 localhost&del "$PluginsDir\test.txt"&rmdir "$PluginsDir"' SW_HIDE ; Cleanup hack
SetOverwrite on
File "/oname=$PluginsDir\test.txt" "${__FILE__}"
SectionEnd 
shekara#
It's a silent install and even in UI it exits without a proper message. It shows onInstFailed message, but bit extract failed. not the ideal situation to be in
Anders#
Does my example display a retry dialog when not silent?

We have no idea what your macros like LogReportAbort are doing...
Anders#
Originally Posted by Anders View Post
Does my example display a retry dialog when not silent?
?...
Anders#
Then there is a bug with /r or something strange happening with your macros.

Using ${if} on a macro parameter is not really something you should be doing when !if might work instead.