반응형
인스톨러 설치 진행 시
실행되는 프로그램의 이름 (제목표시줄의 이름)으로 프로그램을 찾아서
존재하면 인스톨러 진행을 중지하는 방법입니다.
728x90
.nsi 스크립트의 주요 내용
function 정의
Function CheckProcess
FindWindow $0 "" "응용 프로그램"
StrCmp $0 0 done
MessageBox MB_OK "The program is running. Please close the program"
Quit
done:
FunctionEnd
section에 function call
Section "MainSection" SEC01
Call CheckProcess
.
.
SectionEnd
반응형
sample 전체 내용
Unicode true
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "응용 프로그램"
!define PRODUCT_VERSION "0.0.1"
!define PRODUCT_PUBLISHER "나의 회사, Inc."
!define PRODUCT_WEB_SITE "http://www.mycompany.com"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\AppMainExe.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_URL_SCHEME_ROOT_KEY "HKCR"
!define PRODUCT_URL_SCHEME_KEY "testApp"
; MUI 1.67 compatible ------
!include "MUI.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "testAppLicence.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\AppMainExe.exe"
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "Korean"
; MUI end ------
Name "${PRODUCT_NAME}${PRODUCT_VERSION}"
OutFile "testAppInst.exe"
InstallDir "$PROGRAMFILES\응용 프로그램"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Function CheckProcess
FindWindow $0 "" "응용 프로그램"
StrCmp $0 0 done
MessageBox MB_OK "The program is running. Please close the program"
Quit
done:
FunctionEnd
Section "MainSection" SEC01
Call CheckProcess
SetOverwrite try
CreateDirectory "$SMPROGRAMS\응용 프로그램"
CreateShortCut "$SMPROGRAMS\응용 프로그램\응용 프로그램.lnk" "$INSTDIR\AppMainExe.exe"
CreateShortCut "$DESKTOP\응용 프로그램.lnk" "$INSTDIR\AppMainExe.exe"
SetOutPath "$INSTDIR\"
File "Release\AppMainExe.exe"
SetOutPath "$INSTDIR\data1"
File "Release\data1\data1.txt"
SetOutPath "$INSTDIR\data1\data2"
File "Release\data1\data2\data2.txt"
SectionEnd
Section -AdditionalIcons
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\응용 프로그램\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\응용 프로그램\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\AppMainExe.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\AppMainExe.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
WriteRegStr ${PRODUCT_URL_SCHEME_ROOT_KEY} "testApp" "URL Protocol" ""
WriteRegStr ${PRODUCT_URL_SCHEME_ROOT_KEY} "testApp\shell\open\command" "" "$INSTDIR\AppMainExe.exe"
SectionEnd
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name)는(은) 완전히 제거되었습니다."
FunctionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(^Name)을(를) 제거하시겠습니까?" IDYES +2
Abort
FunctionEnd
Section Uninstall
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\AppMainExe.exe"
Delete "$INSTDIR\data1\data1.txt"
Delete "$INSTDIR\data1\data2\data2.txt"
Delete "$SMPROGRAMS\응용 프로그램\Uninstall.lnk"
Delete "$SMPROGRAMS\응용 프로그램\Website.lnk"
Delete "$DESKTOP\응용 프로그램.lnk"
Delete "$SMPROGRAMS\응용 프로그램\응용 프로그램.lnk"
RMDir "$INSTDIR\data1\data2"
RMDir "$INSTDIR\data1"
RMDir "$SMPROGRAMS\응용 프로그램"
RMDir "$INSTDIR"
DeleteRegKey ${PRODUCT_URL_SCHEME_ROOT_KEY} "${PRODUCT_URL_SCHEME_KEY}"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
반응형
LIST
'IT > 개발환경' 카테고리의 다른 글
CentOS 8에 Unity 설치 (0) | 2023.04.19 |
---|---|
CentOS 7에 Unity 설치 (0) | 2023.04.19 |
jq 툴 설치 (0) | 2023.04.18 |
JMeter k8s에 셋팅하기 (비추) (1) | 2023.04.18 |
JMeter 분산 테스팅환경 만들기(2/2) - 부가적인 세부 옵션들 (0) | 2023.04.18 |