Thread: NSIS CopyFiles
View Single Post
Old 29th March 2017, 17:57   #24
Coby
Junior Member
 
Join Date: Feb 2016
Posts: 48
Another way to copy files or folders

#Copy Files

PHP Code:
Name "Copy File"
OutFile "Copy File.exe"
InstallDir "$TEMP\Copy File"

# INCLUDES

!include "MUI2.nsh"
!include "WinCore.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"
!include "FileFunc.nsh"

# Icon & Stye

BrandingText /TRIMRIGHT " "

# Page

Page instfiles "" ""

# LANGUAGES

!insertmacro MUI_LANGUAGE "English" # first language

!define NSIS_SourceFile '!insertmacro NSIS_SourceFile'
!macro NSIS_SourceFile VAR FILE
    Push 
"${FILE}"
     
${GetParent"${FILE}$0
    Pop 
${VAR}
!
macroend

!define NSIS_SourceFolder '!insertmacro NSIS_SourceFolder'
!macro NSIS_SourceFolder VAR FOLDER
    Push 
"${FOLDER}"
     
${GetParent"${FOLDER}$
    Pop 
${VAR}
!
macroend

Section 
"" SEC01

 
# Source File #

 
${NSIS_SourceFile} $"$DESKTOP\Text.txt"
  
DetailPrint "$1"

 
# Destination #

 
${NSIS_SourceFolder} $"$DOCUMENTS"
  
DetailPrint "$2"

 
# Copy #

 
${If} $== $
    CreateDirectory 
`$2
    
CopyFiles /SILENT `$1` `$2
 ${Else} 
    
CreateDirectory `$2
    
CopyFiles /SILENT `$1` `$2
 ${EndIf}  

 ;
SetAutoClose true 
SectionEnd 
#Copy Folders

PHP Code:
Name "Copy Folder"
OutFile "Copy Folder.exe"
InstallDir "$TEMP\Copy Folder"

# INCLUDES

!include "MUI2.nsh"
!include "WinCore.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"
!include "FileFunc.nsh"

# Icon & Stye

BrandingText /TRIMRIGHT " "

# Page

Page instfiles "" ""

# LANGUAGES

!insertmacro MUI_LANGUAGE "English" # first language

!define NSIS_SourceFolder '!insertmacro NSIS_SourceFolder'
!macro NSIS_SourceFolder VAR FOLDER
    Push 
"${FOLDER}"
     
${GetParent"${FOLDER}$
    Pop 
${VAR}
!
macroend

Section 
"" SEC01

 
${NSIS_SourceFolder} $"$DESKTOP\Test"
  
DetailPrint "$1"
 
${NSIS_SourceFolder} $"$DOCUMENTS\Test"
  
DetailPrint "$2"

  
CreateDirectory `$2
  
CopyFiles /SILENT `$1\*.*` `$2`  

 ;
SetAutoClose true 
SectionEnd 
Attached Files
File Type: nsi Copy File.nsi (1.1 KB, 90 views)
File Type: nsi Copy Folder.nsi (802 Bytes, 71 views)
Coby is offline   Reply With Quote