source: ogAgent-Git/windows/ogagent.nsi @ f2af820

browser-nuevodecorare-oglive-methodsexec-ogbrowserfix-urlfixes-winlgromero-filebeatlog-sess-lenmainmodulesnew-browserno-ptt-paramno-tlsogadmcliogadmclient-statusogagent-jobsogagent-macosogcore1oggitogliveoglogoglog2override-moduleping1ping2ping3ping4py3-winpython3qndtestreport-progresssched-tasktlsunification2unification3versionswindows-fixes
Last change on this file since f2af820 was f2af820, checked in by Ramón M. Gómez <ramongomez@…>, 5 years ago

#963: Uninstalling OGAgent for Windows does not require a reboot (you can run OGAgentUninstaller.exe /S for an unattended uninstall).

  • Property mode set to 100644
File size: 7.7 KB
Line 
1# We need http://nsis.sourceforge.net/NSIS_Simple_Firewall_Plugin
2# Copy inside the two x86_xxxxx folders inside nsis plugins folder
3Name "OpenGnsys Agent"
4
5# OpenGnsys Agent version
6!define /file OGA_VERSION "src\VERSION"
7!define /file OGA_WINVERSION "windows\VERSION"
8
9# General Symbol Definitions
10!define REGKEY "SOFTWARE\OGAgent"
11!if ${OGA_VERSION} == ${OGA_WINVERSION}
12  !define VERSION ${OGA_WINVERSION}.0
13!else
14  !define VERSION ${OGA_WINVERSION}.1
15!endif
16!define COMPANY "OpenGnsys Project"
17!define URL https://opengnsys.es
18
19# MultiUser Symbol Definitions
20!define MULTIUSER_EXECUTIONLEVEL Admin
21#!define MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
22!define MULTIUSER_INSTALLMODE_COMMANDLINE
23!define MULTIUSER_INSTALLMODE_INSTDIR OGAgent
24!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${REGKEY}"
25!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUE "Path"
26
27# MUI Symbol Definitions
28!define MUI_ICON "src\img\oga.ico"
29!define MUI_FINISHPAGE_NOAUTOCLOSE
30!define MUI_UNICON "src\img\oga.ico"
31!define MUI_UNFINISHPAGE_NOAUTOCLOSE
32!define MUI_LANGDLL_REGISTRY_ROOT HKLM
33!define MUI_LANGDLL_REGISTRY_KEY ${REGKEY}
34!define MUI_LANGDLL_REGISTRY_VALUENAME InstallerLanguage
35
36# Included files
37!include MultiUser.nsh
38!include Sections.nsh
39!include MUI2.nsh
40
41# Reserved Files
42!insertmacro MUI_RESERVEFILE_LANGDLL
43
44# Variables
45Var StartMenuGroup
46
47# Installer pages
48!insertmacro MUI_PAGE_WELCOME
49!insertmacro MUI_PAGE_LICENSE src\license.txt
50!insertmacro MUI_PAGE_DIRECTORY
51!insertmacro MUI_PAGE_INSTFILES
52!insertmacro MUI_PAGE_FINISH
53!insertmacro MUI_UNPAGE_CONFIRM
54!insertmacro MUI_UNPAGE_INSTFILES
55
56# Installer languages
57!insertmacro MUI_LANGUAGE English
58!insertmacro MUI_LANGUAGE Spanish
59!insertmacro MUI_LANGUAGE French
60!insertmacro MUI_LANGUAGE German
61
62# Installer attributes
63BrandingText "OpenGnsys"
64OutFile OGAgentSetup-${OGA_VERSION}.exe
65InstallDir OGAgent
66CRCCheck on
67XPStyle on
68ShowInstDetails hide
69VIProductVersion "${VERSION}.0.0"
70VIAddVersionKey /LANG=${LANG_ENGLISH} ProductName "OGAgent"
71VIAddVersionKey /LANG=${LANG_ENGLISH} ProductVersion "${VERSION}"
72VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyName "${COMPANY}"
73VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyWebsite "${URL}"
74VIAddVersionKey /LANG=${LANG_ENGLISH} FileVersion "${VERSION}"
75VIAddVersionKey /LANG=${LANG_ENGLISH} FileDescription "OpenGnsys Agent installer"
76VIAddVersionKey /LANG=${LANG_ENGLISH} LegalCopyright "(c) 2015 Virtual Cable S.L.U."
77InstallDirRegKey HKLM "${REGKEY}" Path
78ShowUninstDetails show
79
80# Installer sections
81Section -Main SEC0000
82    SetShellVarContext all
83    SetOutPath $INSTDIR
84    SetOverwrite on
85    File /r bin\*.*
86    File vcredist_x86.exe
87    File src\VERSION
88    WriteRegStr HKLM "${REGKEY}\Components" Main 1
89SectionEnd
90
91Section -post SEC0001
92    SetShellVarContext current
93    WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
94    SetOutPath $INSTDIR
95    WriteUninstaller $INSTDIR\OGAgentUninstaller.exe
96    SetOutPath $SMPROGRAMS\$StartMenuGroup
97    CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk" $INSTDIR\OGAgentUninstaller.exe
98    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
99    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
100    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
101    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
102    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\OGAgentUninstaller.exe
103    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\OGAgentUninstaller.exe
104    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" OGAgentTool $INSTDIR\OGAgentUser.exe
105    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
106    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
107    ExecWait '"$INSTDIR\vcredist_x86.exe" /passive /norestart'
108    # Add the application to the firewall exception list - All Networks - All IP Version - Enabled
109    # SimpleFC::AddApplication "OpenGnsys Agent Service" "$INSTDIR\OGAgentService.exe" 0 2 "" 1
110    # SimpleFC::AdvAddRule [name] [description] [protocol] [direction]
111    #  [status] [profile] [action] [application] [service_name] [icmp_types_and_codes]
112    #  [group] [local_ports] [remote_ports] [local_address] [remote_address]
113    #
114    SimpleFC::AdvAddRule "OpenGnsys Agent Firewall rules" "Firewall rules for OpenGnsys Agent interaction with broker." "6" "1" \
115      "1" "7" "1" "$INSTDIR\OGAgentService.exe" "" "" \
116      "" "" "" "" ""   
117    Pop $0 ; return error(1)/success(0)
118    # Disable fast boot on Windows 10, if registry key exists.
119    ReadRegDWORD $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled
120    IfErrors 0 +2
121    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled 0
122    # Install service
123    nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe --startup auto install" # Add service after installation
124    # Update recovery options
125    nsExec::Exec /OEM "$INSTDIR\OGAServiceHelper.exe"
126SectionEnd
127
128# Macro for selecting uninstaller sections
129!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
130    Push $R0
131    ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
132    StrCmp $R0 1 0 next${UNSECTION_ID}
133    !insertmacro SelectSection "${UNSECTION_ID}"
134    GoTo done${UNSECTION_ID}
135next${UNSECTION_ID}:
136    !insertmacro UnselectSection "${UNSECTION_ID}"
137done${UNSECTION_ID}:
138    Pop $R0
139!macroend
140
141# Uninstaller sections
142Section /o -un.Main UNSEC0000
143    nsExec::Exec "taskkill /F /IM OGAgentUser.exe /T"
144    nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe stop" # Stops the service prior uninstall
145    nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe remove" # Removes the service prior uninstall
146    nsExec::Exec "taskkill /F /IM OGAgentService.exe /T"
147    Delete /REBOOTOK "$INSTDIR\*.*"
148    DeleteRegValue HKLM "${REGKEY}\Components" Main
149    DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" OGAgentTool
150SectionEnd
151
152Section -un.post UNSEC0001
153    # Remove application from the firewall exception list
154    # SimpleFC::RemoveApplication "$INSTDIR\OGAgentService.exe"
155    SimpleFC::AdvRemoveRule "OpenGnsys Agent Firewall rules"
156    Pop $0 ; return error(1)/success(0)
157
158    SetShellVarContext current
159    StrCpy $StartMenuGroup "OpenGnsys Agent"
160    DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
161    Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk"
162    Delete /REBOOTOK $INSTDIR\OGAgentUninstaller.exe
163    DeleteRegValue HKLM "${REGKEY}" Path
164    DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
165    DeleteRegKey /IfEmpty HKLM "${REGKEY}"
166    RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
167    SetShellVarContext all
168    RmDir /r /REBOOTOK $INSTDIR
169SectionEnd
170
171# Installer functions
172Function .onInit
173    InitPluginsDir
174    StrCpy $StartMenuGroup "OpenGnsys Agent"
175   
176    !insertmacro MUI_LANGDLL_DISPLAY
177    !insertmacro MULTIUSER_INIT
178FunctionEnd
179
180# Uninstaller functions
181Function un.onInit
182    StrCpy $StartMenuGroup "OpenGnsys Agent"
183    !insertmacro MUI_UNGETLANGUAGE
184    !insertmacro MULTIUSER_UNINIT
185    !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
186FunctionEnd
187
188# Installer Language Strings
189LangString ^UninstallLink ${LANG_ENGLISH} "Uninstall $(^Name)"
190LangString ^UninstallLink ${LANG_SPANISH} "Desinstalar $(^Name)"
191LangString ^UninstallLink ${LANG_FRENCH} "D�sinstaller $(^Name)"
192LangString ^UninstallLink ${LANG_GERMAN} "deinstallieren $(^Name)"
Note: See TracBrowser for help on using the repository browser.