2016-07-05 1 views

답변

2

컴파일시 외부 도구를 실행하려면 !system 명령을 사용할 수 있습니다. 이 외부 도구/스크립트는 설치 및 제거 지침이 포함 된 파일을 생성해야합니다.

또한 지침을 생성하는 즉시 NSIS를 사용할 수 있지만 당신은 하나의 스크립트에 모두 넣을 때 조금 지저분 : 거의 같은 그것이로

; Generate some files for this example: 
!system 'mkdir "$%temp%\testdir\subdir\sub2\sub3"' 
!appendfile "$%temp%\testdir\file1.txt" "" 
!appendfile "$%temp%\testdir\subdir\file2.txt" "" 
!appendfile "$%temp%\testdir\subdir\sub2\file3.txt" "" 
!appendfile "$%temp%\testdir\subdir\sub2\sub3\file4.txt" "" 



!macro GENFILELIST_Enum SourceDir InstDir 
Push "${SourceDir}" 
Push "${InstDir}" 
Call GENFILELIST_Enum 
!macroend 

### Start editing here ### 

!macro GeneratePages 
OutFile "test.exe" 
Name "Test" 
RequestExecutionLevel admin 
InstallDir "$ProgramFiles\MyTestApp" 

Page Directory 
Page InstFiles 
UninstPage UninstConfirm 
UninstPage InstFiles 
!macroend 

!macro GENFILELIST 
!insertmacro GENFILELIST_Enum "$%temp%\testdir" "" ; Files to install 
!macroend 

!macro GenerateInstallSections FileInstructions 
Section 
SetOutPath $InstDir 
!include "${FileInstructions}" 
WriteUninstaller "$InstDir\Uninst.exe" 
SectionEnd 
!macroend 

!macro GenerateUninstallSections FileInstructions 
Section Uninstall 
SetOutPath $InstDir 
!include "${FileInstructions}" 
SetOutPath $Temp 
Delete "$InstDir\Uninst.exe" 
RmDir $InstDir 
SectionEnd 
!macroend 

### Stop editing here ### 


!ifndef GENFILELIST_IN 
!tempfile GENFILELISTAPP 
!tempfile GENFILELIST_IN 
!tempfile GENFILELIST_UN 
!appendfile "${GENFILELIST_IN}" '!define GENFILELIST_UN "${GENFILELIST_UN}"$\n' 
!appendfile "${GENFILELIST_IN}" 'OutFile "${GENFILELISTAPP}"$\n' 
!system '"${NSISDIR}/makensis" "/DGENFILELIST_IN=${GENFILELIST_IN}" "${__FILE__}"' = 0 
!system '"${GENFILELISTAPP}" /S' = 0 
!delfile "${GENFILELISTAPP}" 
!insertmacro GeneratePages 
!insertmacro GenerateInstallSections "${GENFILELIST_IN}" 
!insertmacro GenerateUninstallSections "${GENFILELIST_UN}" 
!delfile "${GENFILELIST_IN}" 
!delfile "${GENFILELIST_UN}" 
!else 
!include LogicLib.nsh 
!include "${GENFILELIST_IN}" 
!delfile "${GENFILELIST_IN}" 
!macro GENFILELIST_Append file string tmpvar 
FileOpen ${tmpvar} "${file}" a 
FileSeek ${tmpvar} 0 END 
FileWrite ${tmpvar} '${string}' 
FileClose ${tmpvar} 
!macroend 
!define DOLLAR "$$" 
Function GENFILELIST_Enum 
System::Store S 
Pop $9 ; Relative path 
Pop $8 ; Base path 
${IfThen} $9 == "" ${|} StrCpy $9 "${DOLLAR}OutDir" ${|} 
FindFirst $0 $1 "$8\*" 
loop: 
StrCmp $1 "" stop 
    StrCmp $1 "." next 
    StrCmp $1 ".." next 
    StrCpy $3 $1 
    ${If} ${FileExists} "$8\$1\*" 
     !insertmacro GENFILELIST_Append "${GENFILELIST_IN}" 'SetOutPath "${DOLLAR}OutDir\$1"$\n' $2 
     Push $8\$1 
     Push $9\$1 
     Call GENFILELIST_Enum 
    ${Else} 
     !insertmacro GENFILELIST_Append "${GENFILELIST_IN}" 'File "$8\$1"$\n' $2 
     !insertmacro GENFILELIST_Append "${GENFILELIST_UN}" 'Delete "$9\$1"$\n' $2 
    ${EndIf} 
    next: 
    FindNext $0 $1 
    Goto loop 
stop: 
FindClose $0 
!insertmacro GENFILELIST_Append "${GENFILELIST_UN}" 'RmDir "$9"$\n' $2 
System::Store L 
FunctionEnd 
RequestExecutionLevel user 
Section 
!insertmacro GENFILELIST 
SectionEnd 
!endif 
+0

그래서 결과가 위에 언급 한 스크립트를 위해. –