2016-07-05 1 views
0

インストール済みのファイルのみをアンインストールする方法を知りたい。 私はhttp://nsis.sourceforge.net/Uninstall_only_installed_filesを試しましたが、多くのディレクトリにネストされた約10.000個のファイルがあるため、nsisスクリプトで各ファイルを個別に指定するのは解決策ではありません。インストールされているファイルのみをアンインストールするNSIS

答えて

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

ので、結果はかなりそれがあったように同じです私が上記のスクリプトのために。 –

関連する問題