라벨이 NSIS인 게시물 표시

[NSIS] 사설 인증서 등록

# 사용 예 # Call Registering_Certificate_In_Trusted_Root_Certification_Authorities Function Registering_Certificate_In_Trusted_Root_Certification_Authorities # 사설 인증서 등록 (IE, 크롬, 사파리, 오페라) ${AddCertificateToStore} $0 "$VAR_INSTDIR\cert\${CERT_NAME_COMPANY_ROOT_AUTHORITY}" ${If} $0 != success MessageBox MB_OK "certificate import failed: $0" ${EndIf} ${AddCertificateToStore} $0 "$VAR_INSTDIR\cert\${CERT_NAME_DIGICERT_HIGH_ASSURANCE_EV_ROOT_CA}" ${If} $0 != success MessageBox MB_OK "certificate import failed: $0" ${EndIf} ${AddCertificateToStore} $0 "$VAR_INSTDIR\cert\${CERT_NAME_DIGICERT_TRUSTED_ROOT_G4}" ${If} $0 != success MessageBox MB_OK "certificate import failed: $0" ${EndIf} # 사설 인증서 등록 (파이어폭스) System::Call 'shell32::SHGetSpecialFolderPath(i $HWNDPARENT, t .r2, i ${CSIDL_APPDATA}, i0)i.r0' IfFileExists "$2\Mozilla\Firefox\profiles.ini" EXIST_FIREFOX NON_EXIST_FIREFOX EXIST_FIREFOX: ...

[NSIS] 인증서 설치

# https://nsis.sourceforge.io/Import_Root_Certificate # 사용 예 # ${AddCertificateToStore} $0 "$VAR_INSTDIR\rootcert.cer" !define CERT_QUERY_OBJECT_FILE 1 !define CERT_QUERY_CONTENT_FLAG_ALL 16382 !define CERT_QUERY_FORMAT_FLAG_ALL 14 !define CERT_STORE_PROV_SYSTEM 10 !define CERT_STORE_OPEN_EXISTING_FLAG 0x4000 !define CERT_SYSTEM_STORE_LOCAL_MACHINE 0x20000 !define CERT_STORE_ADD_ALWAYS 4 !macro _AddCertificateToStore un Function ${un}_AddCertificateToStore Exch $0 Push $1 Push $R0 System::Call "crypt32::CryptQueryObject(i ${CERT_QUERY_OBJECT_FILE}, w r0, \ i ${CERT_QUERY_CONTENT_FLAG_ALL}, i ${CERT_QUERY_FORMAT_FLAG_ALL}, \ i 0, i 0, i 0, i 0, i 0, i 0, *i .r0) i .R0" ${If} $R0 0 System::Call "crypt32::CertOpenStore(i ${CERT_STORE_PROV_SYSTEM}, i 0, i 0, \ i ${CERT_STORE_OPEN_EXISTING_FLAG}|${CERT_SYSTEM_STORE_LOCAL_MACHINE}, \ w 'ROOT') i .r1" ${If} $1 0 System::Call "crypt32::CertAddCe...

[NSIS] 권한 상승

# https://nsis.sourceforge.io/UAC_plug-in !macro _UAC_Elevation un Function ${un}_UAC_Elevation Push $R0 Exch Pop $R0 uac_tryagain: !insertmacro UAC_RunElevated ${Switch} $0 ${Case} 0 ${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done ${IfThen} $3 0 ${|} ${Break} ${|} ;we are admin, let the show go on ${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "This $R0 requires admin privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0 ${EndIf} ;fall-through and die ${Case} 1223 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "This $R0 requires admin privileges, aborting!" Quit ${Case} 1062 MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!" Quit ${Default} MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to...

[NSIS] 특수 경로 얻어오기

# 설치 경로에 '$'가 포함된 특수 경로이면 해당 경로를 찾아서 SetOutPath 설정, '$'가 포함되어 있지 않으면 들어온 경로 그대로 설정. # 호출 예 # ${GetSpecialPathReplaced} '반환' '특수 경로가 포함된 경로' # ${GetSpecialPathReplaced} $0 "$DESKTOP\test" # $0 == '$DESKTOP 부분이 로컬 PC의 환경에 맞춰 경로를 얻어오고 나머지 뒷 부분은 그대로.' !define CSIDL_DESKTOP '0x0' # Desktop path ($DESKTOP) !define CSIDL_PROGRAMS '0x2' # Programs path !define CSIDL_PERSONAL '0x5' # My document path !define CSIDL_FAVORITES '0x6' # Favorites path ($FAVORITES) !define CSIDL_STARTUP '0x7' # Startup path !define CSIDL_RECENT '0x8' # Recent documents path ($RECENT) !define CSIDL_SENDTO '0x9' # Sendto documents path ($SENDTO) !define CSIDL_STARTMENU '0xB' # StartMenu path !define CSIDL_MUSIC '0xD' # My Music path ($MUSIC) !define CSIDL_DESKTOPDIR '0x10' # Desktop Directory path !define CSIDL_COMPUTER '0x11' # My Compute...

[NSIS] 재배포 패키지 설치 여부 체크 후 설치하는 방법

아래 NSIS 스크립트? 에서 "Function InstallVCRedist_x86" 함수와 "Function CheckVCRedist_x86" 함수 그리고 "Function InstallVCRedist_x64", "Function CheckVCRedist_x64" 함수를 그대로 복사하여 사용하면 된다. (재배포 패키지 Product Code는 수정하여 사용.) ; Script generated by the HM NIS Edit Script Wizard. ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "제품 이름" !define PRODUCT_VERSION "1.0.0.1" !define PRODUCT_PUBLISHER "회사이름 Co., LTD." !define PRODUCT_WEB_SITE "http://www.회사사이트.co.kr" ; "Software\Microsoft\Windows\CurrentVersion\App Paths" 경로의 레지스트리에 키 값을 추가하면 ; "실행" 창에서 입력하여 바로 실행이 가능하다. ; 아래 처럼 추가가 된다면 "실행" 창에 "프로그램명.exe"를 입력하면 프로그램이 실행된다. !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\프로그램명.exe" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" ;...

[NSIS] 32비트와 64비트 모듈 등록하는 법. (regsvr32)

- 등록 x86 환경에선 RegDLL "$SYSDIR\Test.ocx" 처럼 RegDLL 뒤에 등록할 파일의 풀 경로를 입력해 주면 되고 x64 환경에선 ExecWait '"$SYSDIR\regsvr32.exe" /s "$SYSDIR\Text_x64.ocx"' 처럼 regsvr32.exe 프로그램을 통해 등록한다. - 해제 x86 환경에서 UnRegDLL "$SYSDIR\Test.ocx" x64 환경에선 ExecWait '"$SYSDIR\regsvr32.exe" /u /s "$SYSDIR\Test_x64.ocx"' ; Script generated by the HM NIS Edit Script Wizard. ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "제품 이름" !define PRODUCT_VERSION "1.0.0.1" !define PRODUCT_PUBLISHER "회사이름 Co., LTD." !define PRODUCT_WEB_SITE "http://www.회사사이트.co.kr" ; "Software\Microsoft\Windows\CurrentVersion\App Paths" 경로의 레지스트리에 키 값을 추가하면 ; "실행" 창에서 입력하여 바로 실행이 가능하다. ; 아래 처럼 추가가 된다면 "실행" 창에 "프로그램명.exe"를 입력하면 프로그램이 실행된다. !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\프로그램명.exe" !define PRODUCT_UNINST_...

[NSIS] 커맨드 라인 옵션 값 받아오기 + 사일런트 모드 설치

# Command Line 명령어를 받아오기 위해 추가. !include FileFunc.nsh !insertmacro GetParameters !insertmacro GetOptions VAR /GLOBAL PARAM # 전역 변수 선언 Function .onInit ${GetParameters} $PARAM ClearErrors ${GetOptions} $PARAM /SILENT= $PARAM # 여기에서 '/'뒤에 써주는 단어가 커맨드라인 옵션임. 예를 들어 "${GetOptions} $PARAM /TestInput= $PARAM" 이라고 하고, NSIN 빌드 결과 만들어지는 설치 파일 명이 "install.exe"라고 할 때, "install.exe /TestInput=입력값" 이라고 커맨드 라인에서 입력하면 $PARAM에 "입력값"이 들어옴. ; MessageBox MB_OK $PARAM # 값 들어오는지 확인. ex) ["설치 파일 명.exe" /SILENT=test], 라고 했을 때 test가 찍혀야 함. # SetSilent can only be used in .onInit and doesn't work well along with `SetSilent silent' ${If} $PARAM == on ;MessageBox MB_OK "Silent Mode On." SetSilent silent # 설치 시 사일런트 모드로 아무것도 뜨지 않음. ${Else} ;MessageBox MB_OK "Silent Mode Off." SetSilent normal ${EndIf} FunctionEnd

[NSIS] StrLower

# 호출 예 # ${StrLower} '반환' '원본 문자열' # ${StrLower} $0 $1 # ${StrLower} $0 $0 # ${StrLower} $0 "StRiNg" !macro _StrLower un Function ${un}_StrLower Exch $R0 # Original string Push $R1 # Final string Push $R2 # Current character Push $R3 Push $R4 StrCpy $R1 "" Loop: StrCpy $R2 $R0 1 # Get next character StrCmp $R2 "" Done StrCpy $R0 $R0 "" 1 StrCpy $R3 122 # 122 = ASCII code for z Loop2: IntFmt $R4 %c $R3 # Get character from current ASCII code StrCmp $R2 $R4 Match IntOp $R3 $R3 - 1 StrCmp $R3 91 NoMatch Loop2 # 90 = ASCII code one beyond Z Match: StrCpy $R2 $R4 # It 'matches' (either case) so grab the lowercase version NoMatch: StrCpy $R1 $R1$R2 # Append to the final string Goto Loop Done: StrCpy $R0 $R1 # Return the final string Pop $R4 Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd !macroend !insertmacro _StrLower "" ;!insertmacro _StrLo...

[NSIS] Internet Explorer 버전 얻는 함수

# 호출 예 # ${GetIEVersion} '반환' # ${GetIEVersion} $0 !macro _GetIEVersion un Function ${un}_GetIEVersion Push $R0 Push $R1 ClearErrors ReadRegStr $R1 HKLM "Software\Microsoft\Internet Explorer" "svcVersion" # IE 10, 11 IfErrors FAIL_GET_svcVersion SUCCESS_GET_svcVersion SUCCESS_GET_svcVersion: ${IndexOf} $R0 "." $R1 StrCpy $R1 $R1 $R0 Goto lbl_done FAIL_GET_svcVersion: ReadRegStr $R1 HKLM "Software\Microsoft\Internet Explorer" "Version" # IE 9 이하 IfErrors lbl_123 lbl_456 lbl_456: # ie 4+ ${IndexOf} $R0 "." $R1 StrCpy $R1 $R1 $R0 Goto lbl_done lbl_123: # older ie version ClearErrors ReadRegStr $R1 HKLM "Software\Microsoft\Internet Explorer" "IVer" IfErrors lbl_error StrCpy $R1 $R1 3 StrCmp $R1 '100' lbl_ie1 StrCmp $R1 '101' lbl_ie2 StrCmp $R1 '102' lbl_ie2 StrCpy $R1 '3' # default to ie3 if not 10...

[NSIS] Windows 버전 얻는 함수

!macro _GetWindowsVersion un Function ${un}_GetWindowsVersion Push $R0 Push $R1 # check if Windows 10 family (CurrentMajorVersionNumber is new introduced in Windows 10) ReadRegStr $R0 HKLM \ "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentMajorVersionNumber StrCmp $R0 '' 0 lbl_winnt ClearErrors # check if Windows NT family ReadRegStr $R0 HKLM \ "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion IfErrors 0 lbl_winnt # we are not NT ReadRegStr $R0 HKLM \ "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber StrCpy $R1 $R0 1 StrCmp $R1 '4' 0 lbl_error StrCpy $R1 $R0 3 StrCmp $R1 '4.0' lbl_win32_95 StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98 lbl_win32_95: StrCpy $R0 '95' Goto lbl_done lbl_win32_98: StrCpy $R0 '98' Goto lbl_done lbl_win32_ME: StrCpy $R0 'ME' Goto lbl_done lbl_winnt: StrCpy $R1 $R0 1 ...

[NSIS] 원본 문자열의 앞에서부터 원하는 문자의 인덱스 찾기

# 호출 예 # ${IndexOf} '반환' '찾을 문자열' '원본 문자열' # ${IndexOf} $0 "bc" "abcd" # $0 == 1 !macro _IndexOf un Function ${un}_IndexOf Exch $R0 Exch Exch $R1 Push $R2 Push $R3 StrCpy $R3 $R0 StrCpy $R0 -1 IntOp $R0 $R0 + 1 StrCpy $R2 $R3 1 $R0 StrCmp $R2 "" +2 StrCmp $R2 $R1 +2 -3 StrCpy $R0 -1 Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd !macroend !insertmacro _IndexOf "" !insertmacro _IndexOf "un." !macro IndexOf OUTPUT str_find str_origin Push "${str_find}" Push "${str_origin}" !ifndef __UNINSTALL__ Call _IndexOf !else Call un._IndexOf !endif Pop "${OUTPUT}" !macroend !define IndexOf "!insertmacro IndexOf"

[NSIS] 원본 문자열의 뒤에서부터 원하는 문자의 인덱스 찾기

# 호출 예 # ${IndexOf} '반환' '찾을 문자열' '원본 문자열' # ${IndexOf} $0 "b" "abcd" # $0 == 3 !macro _RIndexOf un Function ${un}_RIndexOf Exch $R0 Exch Exch $R1 Push $R2 Push $R3 StrCpy $R3 $R0 StrCpy $R0 0 IntOp $R0 $R0 + 1 StrCpy $R2 $R3 1 -$R0 StrCmp $R2 "" +2 StrCmp $R2 $R1 +2 -3 StrCpy $R0 -1 Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd !macroend !insertmacro _RIndexOf "" !insertmacro _RIndexOf "un." !macro RIndexOf OUTPUT str_find str_origin Push "${str_find}" Push "${str_origin}" !ifndef __UNINSTALL__ Call _RIndexOf !else Call un._RIndexOf !endif Pop "${OUTPUT}" !macroend !define RIndexOf "!insertmacro RIndexOf"

[NSIS] 문자열에 원하는 문자열이 포함되어 있는지 체크하는 함수

# 호출 예 # ${StrContains} '반환' '찾을 문자열' '원본 문자열' # ${StrContains} $0 "tri" "The String" # 성공 시 $0 == "tri", 실패 시 $0 == "" !macro _StrContains un Function ${un}_StrContains Push $R0 # 찾을 문자열 Exch Pop $R0 Push $R1 # 원본 문자열 Exch 2 Pop $R1 Push $R2 # 리턴 문자열 Push $R3 Push $R4 Push $R5 Push $R6 ;MessageBox MB_OK "찾을 문자열[$R0], 원본 문자열[$R1]" StrCpy $R2 "" StrCpy $R3 -1 StrLen $R4 $R0 StrLen $R6 $R1 loop: IntOp $R3 $R3 + 1 StrCpy $R5 $R1 $R4 $R3 StrCmp $R5 $R0 found StrCmp $R3 $R6 done Goto loop found: StrCpy $R2 $R0 Goto done done: Pop $R6 Pop $R5 Pop $R4 Pop $R3 Exch $R2 Exch Pop $R0 Exch Pop $R1 FunctionEnd !macroend !insertmacro _StrContains "" !insertmacro _StrContains "un." !macro StrContains OUTPUT str_find str_origin Push "${str_origin}" Push "${str_find}" !ifndef __UNINSTALL__ ...

[NSIS] 문자열에서 찾아 바꾸기

# 호출 예 # ${StrReplace} '반환' '찾을 문자열' '바꿀 문자열' '원본 문자열' # ${StrReplace} $0 "like" "don't like" "I like cheese a lot!" # $0 == I don't like cheese a lot! !macro _StrReplace un Function ${un}_StrReplace Push $R0 # 원본 문자열 Exch Pop $R0 Push $R1 Exch 2 Pop $R1  # 바꿀 문자열 Push $R2 Exch 3 Pop $R2 Push $R3 Push $R4 Push $R5 Push $R6 Push $R7 Push $R8 StrCpy $R3 -1 StrLen $R5 $R0 StrLen $R6 $R1 StrLen $R7 $R2 Loop: IntOp $R3 $R3 + 1 StrCpy $R4 $R0 $R7 $R3 StrCmp $R3 $R5 End StrCmp $R4 $R2 0 Loop StrCpy $R4 $R0 $R3 IntOp $R8 $R3 + $R7 StrCpy $R8 $R0 "" $R8 StrCpy $R0 $R4 $R1 $R8 IntOp $R3 $R3 + $R6 IntOp $R3 $R3 - 1 IntOp $R5 $R5 - $R7 IntOp $R5 $R5 + $R6 Goto Loop End: Pop $R8 Pop $R7 Pop $R6 Pop $R5 Pop $R4 Pop $R3 Push $R0 Exch Pop $R0 Exch Pop $R1 Exch Pop $R2 FunctionEnd !macroend !insertmacro _StrRep...

[NSIS] Install 영역과 Uninstall 영역 모두에서 호출 가능한 함수? 매크로? 기본 포맷

!macro _FuncName un Function ${un}_FuncName # 함수 정의 Pop $0 MessageBox MB_OK "_FuncName [$0]" Push "return $0 from _FuncName" FunctionEnd !macroend !insertmacro _FuncName "" !insertmacro _FuncName "un." !macro FuncName OUTPUT param Push "${param}" !ifndef __UNINSTALL__ Call _FuncName !else Call un._FuncName !endif Pop "${OUTPUT}" !macroend !define FuncName "!insertmacro FuncName" !macro _FuncName2 un Function ${un}_FuncName2 # 함수 정의 Pop $1 MessageBox MB_OK "_FuncName2 [$1]" ${FuncName} $0 "test $1" MessageBox MB_OK "_FuncName2 000 [$0]" FunctionEnd !macroend !insertmacro _FuncName2 "" !insertmacro _FuncName2 "un." !macro FuncName2 param Push "${param}" !ifndef __UNINSTALL__ Call _FuncName2 !else Call un._FuncName2 !endif !macroend !define FuncName2 "!insertmacro FuncName2" 호출은 'install...

[NSIS] 실행되는(설치 파일) 자기 경로 얻어오기

System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1' ;$R0 will contain the installer filename MessageBox MB_OK "$R0"

[NSIS] 참고용 샘플

샘플 다운로드

[NSIS] FindProcDLL

플러그인 다운로드 https://nsis.sourceforge.io/FindProcDLL_plug-in 위 링크 페이지에서 바로 보이는 dll을 받으면 인터페이스가 "FindProc" 밖에 없다. 첨부된 파일은 위 링크에서 "Download: forum post | direct link " 라고 되어있는 링크에서 다운받은 파일이다. forum post : http://forums.winamp.com/showpost.php?p=2777729&postcount=8 위 링크에서 받은 dll만 FindProc, KillProc, WaitProcEnd, WaitProcStart 인터페이스가 있다.