; The Jarvis installer (admin.spec.md, "Installer"). Built on Linux by installer.sh with makensis: ; makensis -DVERSION=0.1.0 -DSRC= -DOUT= -DICON= -DWEBVIEW2= installer.nsi ; Program Files, one administrator prompt; the data folder is chosen by the app's first-run wizard ; and never touched here. /S installs silently (the app's updates: /S /RUN starts the app afterwards). Unicode true SetCompressor /SOLID lzma !include "MUI2.nsh" !include "x64.nsh" !include "LogicLib.nsh" !include "FileFunc.nsh" !define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\JarvisBot" !define WEBVIEW2_KEY "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name "Jarvis" OutFile "${OUT}" InstallDir "$PROGRAMFILES64\Jarvis" InstallDirRegKey HKLM "Software\JarvisBot" "InstallDir" RequestExecutionLevel admin BrandingText "Jarvis ${VERSION}" VIProductVersion "${VERSION}.0" VIAddVersionKey /LANG=0 "ProductName" "Jarvis" VIAddVersionKey /LANG=0 "FileVersion" "${VERSION}" VIAddVersionKey /LANG=0 "FileDescription" "Jarvis 설치" VIAddVersionKey /LANG=0 "LegalCopyright" "MIT" !define MUI_ICON "${ICON}" !define MUI_UNICON "${ICON}" !define MUI_ABORTWARNING !define MUI_FINISHPAGE_RUN !define MUI_FINISHPAGE_RUN_TEXT "Jarvis 실행" !define MUI_FINISHPAGE_RUN_FUNCTION RunAsUser !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_LANGUAGE "Korean" ; Whether jarvis.exe runs (any user's), from tasklist's answer: OUT = 1 or 0. !macro JarvisRuns PREFIX OUT nsExec::ExecToStack 'tasklist /FI "IMAGENAME eq jarvis.exe" /NH' Pop $0 Call ${PREFIX}StrHasJarvis Pop ${OUT} !macroend !macro StrHasJarvisFn PREFIX Function ${PREFIX}StrHasJarvis Exch $R0 Push $R1 Push $R2 Push $R3 StrCpy $R1 0 StrCpy $R2 0 loop: StrCpy $R3 $R0 10 $R1 StrCmp $R3 "" done StrCmp $R3 "jarvis.exe" found IntOp $R1 $R1 + 1 Goto loop found: StrCpy $R2 1 done: StrCpy $R0 $R2 Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd !macroend !insertmacro StrHasJarvisFn "" !insertmacro StrHasJarvisFn "un." ; Wait until Jarvis has closed: silently up to 60 s (an update closes it itself), else ask. !macro WaitClosed PREFIX StrCpy $5 0 ${Do} !insertmacro JarvisRuns "${PREFIX}" $4 ${If} $4 == 0 ${Break} ${EndIf} ${If} ${Silent} ${If} $5 >= 60 Abort ${EndIf} Sleep 1000 IntOp $5 $5 + 1 ${Else} MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "Jarvis가 실행 중입니다. Jarvis 창을 닫은 뒤 다시 시도를 눌러 주세요." IDRETRY +2 Abort ${EndIf} ${Loop} !macroend Function .onInit ${IfNot} ${RunningX64} MessageBox MB_ICONSTOP "Jarvis는 64비트 Windows 10/11에서만 실행됩니다." Abort ${EndIf} SetRegView 64 ; Shortcuts for every user of the PC, like the Program Files install itself. SetShellVarContext all !insertmacro WaitClosed "" FunctionEnd Function un.onInit SetRegView 64 SetShellVarContext all !insertmacro WaitClosed "un." FunctionEnd ; Started from this elevated installer the app would run as administrator; Explorer starts it as ; the signed-in user. Function RunAsUser Exec '"$WINDIR\explorer.exe" "$INSTDIR\jarvis.exe"' FunctionEnd Section "Jarvis (필수)" SecMain SectionIn RO SetOutPath "$INSTDIR" File "${SRC}/jarvis.exe" File "${SRC}/WebView2Loader.dll" File /r "${SRC}/python-src" File /r "${SRC}/display-driver" WriteUninstaller "$INSTDIR\uninstall.exe" WriteRegStr HKLM "Software\JarvisBot" "InstallDir" "$INSTDIR" WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "Jarvis" WriteRegStr HKLM "${UNINST_KEY}" "DisplayVersion" "${VERSION}" WriteRegStr HKLM "${UNINST_KEY}" "Publisher" "Jarvis" WriteRegStr HKLM "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\jarvis.exe" WriteRegStr HKLM "${UNINST_KEY}" "InstallLocation" "$INSTDIR" WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKLM "${UNINST_KEY}" "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S' WriteRegDWORD HKLM "${UNINST_KEY}" "NoModify" 1 WriteRegDWORD HKLM "${UNINST_KEY}" "NoRepair" 1 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 WriteRegDWORD HKLM "${UNINST_KEY}" "EstimatedSize" $0 ; The window needs the WebView2 runtime (Windows 11 has it; an older Windows 10 may not). ReadRegStr $0 HKLM "${WEBVIEW2_KEY}" "pv" ReadRegStr $1 HKCU "${WEBVIEW2_KEY}" "pv" ${If} $0 == "" ${OrIf} $0 == "0.0.0.0" ${If} $1 == "" ${OrIf} $1 == "0.0.0.0" DetailPrint "WebView2 런타임 설치" SetOutPath "$PLUGINSDIR" File "/oname=webview2.exe" "${WEBVIEW2}" ExecWait '"$PLUGINSDIR\webview2.exe" /silent /install' $0 DetailPrint "WebView2 설치 결과: $0" SetOutPath "$INSTDIR" ${EndIf} ${EndIf} ; Silent updates (/S /RUN) start the app again when done. ${GetParameters} $0 ClearErrors ${GetOptions} $0 "/RUN" $1 ${IfNot} ${Errors} Call RunAsUser ${EndIf} SectionEnd Section "시작 메뉴 바로 가기" SecStart CreateShortCut "$SMPROGRAMS\Jarvis.lnk" "$INSTDIR\jarvis.exe" SectionEnd Section /o "바탕 화면 바로 가기" SecDesktop CreateShortCut "$DESKTOP\Jarvis.lnk" "$INSTDIR\jarvis.exe" SectionEnd Section /o "가상 모니터 드라이버" SecDriver ; The app's own elevated half (admin.spec.md, "Virtual monitor"); Windows asks once whether to ; trust the SignPath Foundation. It can also be installed later from the features screen. ExecWait '"$INSTDIR\jarvis.exe" --display-driver install --result "$PLUGINSDIR\vdd.txt"' $0 ${If} $0 != 0 FileOpen $1 "$PLUGINSDIR\vdd.txt" r FileRead $1 $2 FileClose $1 DetailPrint "가상 모니터 드라이버를 설치하지 못했습니다: $2" ${IfNot} ${Silent} MessageBox MB_ICONEXCLAMATION "가상 모니터 드라이버를 설치하지 못했습니다. 나중에 기능 화면에서 다시 설치할 수 있습니다.$\r$\n$2" ${EndIf} ${EndIf} SectionEnd LangString DESC_Main ${LANG_KOREAN} "관리 앱과 음성 워커·두뇌 소스입니다. 모델과 런타임은 첫 실행 때 고른 데이터 폴더에 받습니다." LangString DESC_Driver ${LANG_KOREAN} "봇용 크롬창을 실제 모니터에 보이지 않는 가상 모니터에 두어 디스코드 화면 공유에서 고를 수 있게 합니다. Windows가 장치 소프트웨어 설치를 한 번 묻습니다." !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecMain} $(DESC_Main) !insertmacro MUI_DESCRIPTION_TEXT ${SecDriver} $(DESC_Driver) !insertmacro MUI_FUNCTION_DESCRIPTION_END Section "Uninstall" ; The virtual monitor's driver goes with the app when this app installed it (the elevated half ; refuses another program's copy and does nothing when there is none). ExecWait '"$INSTDIR\jarvis.exe" --display-driver uninstall --result "$TEMP\jarvis-vdd-uninstall.txt"' Delete "$TEMP\jarvis-vdd-uninstall.txt" ; Only what the installer put there: a folder the person chose may hold other things. Delete "$INSTDIR\jarvis.exe" Delete "$INSTDIR\WebView2Loader.dll" RMDir /r "$INSTDIR\python-src" RMDir /r "$INSTDIR\display-driver" Delete "$INSTDIR\uninstall.exe" RMDir "$INSTDIR" Delete "$SMPROGRAMS\Jarvis.lnk" Delete "$DESKTOP\Jarvis.lnk" DeleteRegKey HKLM "${UNINST_KEY}" DeleteRegKey HKLM "Software\JarvisBot" DetailPrint "데이터 폴더(모델, 대화 기록, 설정)는 지우지 않았습니다." SectionEnd