Old 20th August 2021, 08:23   #1
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
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 is offline   Reply With Quote
Old 20th August 2021, 10:09   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
Is it the source or destination that is locked?

Fails how? Does it display a message?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 20th August 2021, 10:34   #3
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
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.
shekara is offline   Reply With Quote
Old 20th August 2021, 11:39   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
If it does not fail in makensis then it is not the source.


This will display a dialog when not running in silent mode:
PHP Code:
Section
InitPluginsDir
FileOpen 
$"$PluginsDir\test.txt" 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 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 20th August 2021, 14:57   #5
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
it's not at source..it is the destination
shekara is offline   Reply With Quote
Old 20th August 2021, 22:04   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
Does you get a error dialog or not? Are you running in silent mode?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st August 2021, 03:51   #7
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
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
shekara is offline   Reply With Quote
Old 21st August 2021, 20:33   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
Does my example display a retry dialog when not silent?

We have no idea what your macros like LogReportAbort are doing...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd August 2021, 12:44   #9
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
Abort writes the error message onto the log and quits the installer.
shekara is offline   Reply With Quote
Old 22nd August 2021, 17:46   #10
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
Quote:
Originally Posted by Anders View Post
Does my example display a retry dialog when not silent?
?...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 23rd August 2021, 11:10   #11
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
yes it does
shekara is offline   Reply With Quote
Old 23rd August 2021, 22:50   #12
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump