📄 remembercomponents.nsi
字号:
;-----------------------------------------------------------------------------------------------
; Remember installed and uninstalled components
;
; 2005 Shengalts Aleksander aka Instructor (Shengalts@mail.ru)
;-----------------------------------------------------------------------------------------------
!define NAME "Remember Components"
!define OUTFILE "RememberComponents.exe"
!define REG_ROOT "HKLM"
!define REG_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RememberComponents"
!define UNINSTALLER "$EXEDIR\RememberComponentsUninstall.exe"
Name "${NAME}"
OutFile "${OUTFILE}"
!include "WordFunc.nsh"
!insertmacro WordFind
!insertmacro WordFind2X
!insertmacro WordAdd
!insertmacro un.WordFind2X
!insertmacro un.WordAdd
Var NEW
Var OLD
Page components
Page instfiles
ComponentText "" "" "Try to install - uninstall different combination of components"
UninstPage components
UninstPage instfiles
### Install ###
Function .onInit
ReadRegStr $OLD ${REG_ROOT} "${REG_KEY}" "InstalledComponents"
ClearErrors
StrCmp $OLD '' AllSelect OldSelect
AllSelect:
StrCpy $2 0
SectionSetFlags $2 1
IfErrors end
IntOp $2 $2 + 1
goto -3
OldSelect:
StrCpy $2 1
loop:
${WordFind2X} "$OLD" "[" "." "E+$2" $0
IfErrors end
SectionSetFlags $0 1
IntOp $2 $2 + 1
goto loop
end:
FunctionEnd
Section /o "a"
StrCpy $NEW "[0.a]"
SectionEnd
Section /o "b"
StrCpy $NEW "$NEW [1.b]"
SectionEnd
Section /o "c"
StrCpy $NEW "$NEW [2.c]"
SectionEnd
Section /o "d"
StrCpy $NEW "$NEW [3.d]"
SectionEnd
Section "-install"
StrCmp $NEW '' 0 EditStr
MessageBox MB_OK "Nothing is selected"
goto end
EditStr:
StrCmp $OLD '' WriteStr
${WordAdd} "$OLD" " " "+$NEW" $NEW
StrCmp $OLD $NEW 0 WriteStr
MessageBox MB_OK "Old components was reinstalled"
goto WriteUn
WriteStr:
WriteRegStr ${REG_ROOT} "${REG_KEY}" "InstalledComponents" "$NEW"
WriteRegStr ${REG_ROOT} "${REG_KEY}" "DisplayName" "${NAME}"
MessageBox MB_OK "Selected components installed"
WriteUn:
WriteRegStr ${REG_ROOT} "${REG_KEY}" "UninstallString" "${UNINSTALLER}"
WriteUninstaller "${UNINSTALLER}"
end:
quit
SectionEnd
### Uninstall ###
Function un.onInit
ReadRegStr $OLD ${REG_ROOT} "${REG_KEY}" "InstalledComponents"
StrCmp $OLD '' 0 Select
MessageBox MB_OK "Nothing is installed"
quit
Select:
StrCpy $2 1
loop:
${un.WordFind2X} "$OLD" "[" "." "E+$2" $0
IfErrors end
SectionSetFlags $0 1
IntOp $2 $2 + 1
goto loop
end:
FunctionEnd
Section /o "un.a"
SectionIn RO
StrCpy $NEW "[0.a]"
SectionEnd
Section /o "un.b"
SectionIn RO
StrCpy $NEW "$NEW [1.b]"
SectionEnd
Section /o "un.c"
SectionIn RO
StrCpy $NEW "$NEW [2.c]"
SectionEnd
Section /o "un.d"
SectionIn RO
StrCpy $NEW "$NEW [3.d]"
SectionEnd
Section "-un.install"
StrCmp $NEW '' 0 EditStr
MessageBox MB_OK "Nothing is selected"
goto end
EditStr:
${un.WordAdd} "$OLD" " " "-$NEW" $NEW
StrCmp $NEW '' 0 WriteStr
ReadRegStr $0 ${REG_ROOT} "${REG_KEY}" "UninstallString"
DeleteRegKey ${REG_ROOT} "${REG_KEY}"
Delete $0
MessageBox MB_OK "All components uninstalled"
goto end
WriteStr:
WriteRegStr ${REG_ROOT} "${REG_KEY}" "InstalledComponents" "$NEW"
MessageBox MB_OK "Selected components uninstalled"
end:
quit
SectionEnd
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -