1+
2+ !define FULLNAME " Mouse Commander Native Client"
3+ !define APPNAME " mousecommander"
4+
5+
6+ !include MUI2.nsh
7+ !include FileFunc.nsh
8+
9+ ; --------------------------------
10+ ; Perform Machine-level install, if possible
11+
12+ !define MULTIUSER_EXECUTIONLEVEL Highest
13+ ; Add support for command-line args that let uninstaller know whether to
14+ ; uninstall machine- or user installation:
15+ !define MULTIUSER_INSTALLMODE_COMMANDLINE
16+ !include MultiUser.nsh
17+ !include LogicLib.nsh
18+
19+ Function .onInit
20+ !insertmacro MULTIUSER_INIT
21+ ; Do not use InstallDir at all so we can detect empty $InstDir!
22+ ${If} $InstDir == " " ; /D not used
23+ ${If} $MultiUser .InstallMode == " AllUsers"
24+ StrCpy $InstDir " $PROGRAMFILES\${FULLNAME}"
25+ ${Else}
26+ StrCpy $InstDir " $LOCALAPPDATA\${FULLNAME}"
27+ ${EndIf}
28+ ${EndIf}
29+ FunctionEnd
30+
31+ Function un.onInit
32+ !insertmacro MULTIUSER_UNINIT
33+ FunctionEnd
34+
35+ ; --------------------------------
36+ ; General
37+
38+ Name " ${FULLNAME}"
39+ OutFile " ..\${APPNAME}-client-setup.exe"
40+
41+ ; --------------------------------
42+ ; Interface Settings
43+
44+ !define MUI_ABORTWARNING
45+
46+ ; --------------------------------
47+ ; Pages
48+
49+ !define MUI_WELCOMEPAGE_TEXT " This wizard will guide you through the installation of ${FULLNAME}.$\r$\n$\r$\n$\r$\n Click Next to continue."
50+ !insertmacro MUI_PAGE_WELCOME
51+ !insertmacro MUI_PAGE_DIRECTORY
52+ !insertmacro MUI_PAGE_INSTFILES
53+ !define MUI_FINISHPAGE_NOAUTOCLOSE
54+ !define MUI_FINISHPAGE_RUN
55+ !define MUI_FINISHPAGE_RUN_CHECKED
56+ !define MUI_FINISHPAGE_RUN_TEXT " Run ${FULLNAME}"
57+ !define MUI_FINISHPAGE_RUN_FUNCTION " LaunchLink"
58+ !insertmacro MUI_PAGE_FINISH
59+
60+ !insertmacro MUI_UNPAGE_CONFIRM
61+ !insertmacro MUI_UNPAGE_INSTFILES
62+
63+ ; --------------------------------
64+ ; Languages
65+
66+ !insertmacro MUI_LANGUAGE " English"
67+
68+ ; --------------------------------
69+ ; Installer Sections
70+
71+ !define UNINST_KEY \
72+ " Software\Microsoft\Windows\CurrentVersion\Uninstall\${FULLNAME}"
73+ !define MANIFEST_KEY \
74+ " Software\Mozilla\NativeMessagingHosts\${APPNAME}"
75+ Section
76+ SetOutPath " $InstDir"
77+ File /r " ..\${APPNAME}\*"
78+ nsJSON::Set /file " $InstDir\${APPNAME}.json"
79+ nsJSON::Quote /always ` $InstDir\${APPNAME}.exe`
80+ Pop $R0
81+ nsJSON::Set ` path` /value ` $R0`
82+ nsJSON::Serialize /format /file " $InstDir\${APPNAME}.json"
83+ WriteRegStr SHCTX " ${MANIFEST_KEY}" " " " $InstDir\${APPNAME}.json"
84+ WriteRegStr SHCTX " Software\${FULLNAME}" " " $InstDir
85+ WriteUninstaller " $InstDir\uninstall.exe"
86+ CreateShortCut " $SMPROGRAMS\${FULLNAME}.lnk" " $InstDir\${APPNAME}.exe"
87+ WriteRegStr SHCTX " ${UNINST_KEY}" " DisplayName" " ${FULLNAME}"
88+ WriteRegStr SHCTX " ${UNINST_KEY}" " UninstallString" \
89+ " $\" $InstDir\uninstall.exe$\" /$MultiUser.InstallMode"
90+ WriteRegStr SHCTX " ${UNINST_KEY}" " QuietUninstallString" \
91+ " $\" $InstDir\uninstall.exe$\" /$MultiUser.InstallMode /S"
92+ WriteRegStr SHCTX " ${UNINST_KEY}" " Publisher" " tumpio"
93+ ${GetSize} " $InstDir" " /S=0K" $0 $1 $2
94+ IntFmt $0 " 0x%08X" $0
95+ WriteRegDWORD SHCTX " ${UNINST_KEY}" " EstimatedSize" " $0"
96+
97+ SectionEnd
98+
99+ ; --------------------------------
100+ ; Uninstaller Section
101+
102+ Section " Uninstall"
103+
104+ RMDir /r " $InstDir"
105+ Delete " $SMPROGRAMS\${FULLNAME}.lnk"
106+ DeleteRegKey /ifempty SHCTX " Software\${FULLNAME}"
107+ DeleteRegKey SHCTX " ${MANIFEST_KEY}"
108+ DeleteRegKey SHCTX " ${UNINST_KEY}"
109+
110+ SectionEnd
111+
112+ Function LaunchLink
113+ !addplugindir " ."
114+ ShellExecAsUser::ShellExecAsUser " open" " $SMPROGRAMS\${FULLNAME}.lnk"
115+ FunctionEnd
0 commit comments