3 ; $Source: /cvsroot/ijbswa/winsetup/privoxy_winthreads.nsi,v $
6 ; NSIS script to make the Privoxy installer
8 ; This .NSI script is designed for NSIS v2.24+
10 ; Get NSIS from: http://www.nullsoft.com/free/nsis/
13 ; Written by and Copyright (C) 2007-2009 the Privoxy team.
14 ; https://www.privoxy.org/
16 ; This script originally written by and Copyright (C) 2002
19 ; This program is free software; you can redistribute it
20 ; and/or modify it under the terms of the GNU General
21 ; Public License as published by the Free Software
22 ; Foundation; either version 2 of the License, or (at
23 ; your option) any later version.
25 ; This program is distributed in the hope that it will
26 ; be useful, but WITHOUT ANY WARRANTY; without even the
27 ; implied warranty of MERCHANTABILITY or FITNESS FOR A
28 ; PARTICULAR PURPOSE. See the GNU General Public
29 ; License for more details.
31 ; The GNU General Public License should be included with
32 ; this file. If not, you can view it at
33 ; http://www.gnu.org/copyleft/gpl.html
34 ; or write to the Free Software Foundation, Inc., 59
35 ; Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 !include WinMessages.nsh ; to send close message to Privoxy process
42 Var /GLOBAL UpdateExisting
44 ;win7 RequestExecutionLevel admin
47 ; Close Privoxy and wait for termination
51 FindWindow $R0 "PrivoxyLogOwner"
52 IntCmpU $R0 0 NoPrivoxyRunning 0 0
53 SendMessage $R0 ${WM_CLOSE} 0 0
57 Sleep 200 ; avoid file in use error
58 FindWindow $R0 "PrivoxyLogOwner"
59 IntCmpU $R0 0 NoPrivoxyRunning 0 0
61 IntCmp $R1 20 0 CheckWindowClosed 0
62 Sleep 200 ; avoid file in use error
67 ; create a backup file if file exists, set $UpdateExisting on existing files
69 !macro BackupOLD Name BackupName
70 !define UniqueID ${__LINE__}
72 IfFileExists "$INSTDIR\${Name}" 0 skip_${UniqueID}
73 StrCpy $UpdateExisting 1
74 delete "$INSTDIR\${BackupName}"
75 rename "$INSTDIR\${Name}" "$INSTDIR\${BackupName}"
82 ; check file, write new one to different target there is one, set $UpdateExisting on existing files
84 !macro KeepCur Name DefaultName SrcDir
85 !define UniqueID ${__LINE__}
87 IfFileExists "$INSTDIR\${Name}" 0 new_${UniqueID}
88 StrCpy $UpdateExisting 1
89 delete "$INSTDIR\${DefaultName}"
90 File "/oname=${DefaultName}" "${SrcDir}${Name}"
94 File "${SrcDir}${Name}"
103 OutFile "privoxy_setup.exe"
107 ; Some default compiler settings (uncomment and change at will):
108 SetCompress auto ; (can be off or force)
109 SetCompressor /FINAL /SOLID lzma
110 SetDatablockOptimize on
112 AutoCloseWindow true ; (can be true for the window go away automatically at end)
113 ShowInstDetails nevershow ; (can be show to have them shown, or nevershow to disable)
114 SetDateSave on ; (can be on to have files restored to their orginal date)
115 ; SetOverwrite ifnewer ; (files are only overwritten if the existing file is older than the new file)
116 SetOverwrite on ; install package files over-write existing files regardless of date
119 UninstallIcon "uninstall_privoxy.ico"
121 #LicenseText "Privoxy is distributed under the GNU General Public License. Please read it before you install."
122 #LicenseData "build/LICENSE.txt"
124 InstallDir "$PROGRAMFILES\Privoxy"
125 ;InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Privoxy.org\Privoxy" ""
126 ;DirShow show ; (make this hide to not let the user change it)
127 ;DirShow doesn't currently work.
128 DirText "Select the directory to install Privoxy in:"
130 ComponentText "Please select how you want to start Privoxy:"
132 Section "" ; (default section)
133 StrCpy $UpdateExisting 0
135 ; Close privoxy.exe if it is running (user is upgrading) to prevent in-use errors.
136 !insertmacro ClosePrivoxy
138 ; add files / whatever that need to be installed here.
139 SetOutPath "$INSTDIR"
141 ; save files the user might have changed
142 ; config.txt match-all.action trust.txt
144 !insertmacro BackupOLD "config.txt" "old_config.txt"
145 !insertmacro BackupOLD "match-all.action" "old_match-all.action";
146 !insertmacro BackupOLD "trust.txt" "old_trust.txt"
150 ; leave user.action and user.filter alone if they exist
152 !insertmacro KeepCur "user.action" "clean_user.action" "build\"
153 !insertmacro KeepCur "user.filter" "clean_user.filter" "build\"
154 ; exclude all files handled by KeepCur
155 File /r /x CVS /x user.action /x user.filter build\*.*
157 ;WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Privoxy.org\Privoxy" "" "$INSTDIR"
158 WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\Privoxy" "DisplayName" "Privoxy (remove only)"
159 WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\Privoxy" "UninstallString" '"$INSTDIR\privoxy_uninstall.exe"'
161 WriteRegStr HKEY_CLASSES_ROOT "PrivoxyActionFile\shell\open\command" "" 'Notepad.exe "%1"'
162 WriteRegStr HKEY_CLASSES_ROOT ".action" "" "PrivoxyActionFile"
163 WriteRegStr HKEY_CLASSES_ROOT "PrivoxyFilterFile\shell\open\command" "" 'Notepad.exe "%1"'
164 WriteRegStr HKEY_CLASSES_ROOT ".filter" "" "PrivoxyFilterFile"
166 WriteUninstaller "privoxy_uninstall.exe"
169 Section "Add to Start Menu"
170 SetShellVarContext all ; (Add to "All Users" Start Menu if possible)
171 RMDir /r "$SMPROGRAMS\Privoxy"
172 CreateDirectory "$SMPROGRAMS\Privoxy"
173 CreateShortCut "$SMPROGRAMS\Privoxy\Privoxy.lnk" "$INSTDIR\privoxy.exe"
174 WriteINIStr "$SMPROGRAMS\Privoxy\Web-based Configuration.url" "InternetShortcut" "URL" "http://config.privoxy.org/"
175 CreateShortCut "$SMPROGRAMS\Privoxy\Web-based Feedback.lnk" "$INSTDIR\doc\user-manual\contact.html"
176 CreateDirectory "$SMPROGRAMS\Privoxy\Edit Config"
177 CreateShortCut "$SMPROGRAMS\Privoxy\Edit Config\Main Configuration.lnk" "Notepad.exe" '"$INSTDIR\config.txt"'
178 CreateShortCut "$SMPROGRAMS\Privoxy\Edit Config\Default Actions.lnk" "Notepad.exe" '"$INSTDIR\default.action"'
179 CreateShortCut "$SMPROGRAMS\Privoxy\Edit Config\User Actions.lnk" "Notepad.exe" '"$INSTDIR\user.action"'
180 CreateShortCut "$SMPROGRAMS\Privoxy\Edit Config\Filters.lnk" "Notepad.exe" '"$INSTDIR\default.filter"'
181 CreateShortCut "$SMPROGRAMS\Privoxy\Edit Config\Trust list.lnk" "Notepad.exe" '"$INSTDIR\trust.txt"'
182 CreateDirectory "$SMPROGRAMS\Privoxy\Documentation"
183 CreateShortCut "$SMPROGRAMS\Privoxy\Documentation\User Manual.lnk" "$INSTDIR\doc\user-manual\index.html"
184 CreateShortCut "$SMPROGRAMS\Privoxy\Documentation\Frequently Asked Questions.lnk" "$INSTDIR\doc\faq\index.html"
185 CreateShortCut "$SMPROGRAMS\Privoxy\Documentation\Credits.lnk" "Notepad.exe" '"$INSTDIR\AUTHORS.txt"'
186 CreateShortCut "$SMPROGRAMS\Privoxy\Documentation\License.lnk" "Notepad.exe" '"$INSTDIR\LICENSE.txt"'
187 CreateShortCut "$SMPROGRAMS\Privoxy\Documentation\ReadMe file.lnk" "Notepad.exe" '"$INSTDIR\README.txt"'
188 WriteINIStr "$SMPROGRAMS\Privoxy\Documentation\Web Site.url" "InternetShortcut" "URL" "http://privoxy.org/"
189 CreateShortCut "$SMPROGRAMS\Privoxy\Uninstall Privoxy.lnk" "$INSTDIR\privoxy_uninstall.exe"
193 Section "Run automatically at startup"
194 CreateShortCut "$SMSTARTUP\Privoxy.lnk" "$INSTDIR\privoxy.exe" "" "" 0 SW_SHOWMINIMIZED
198 Function .onInstSuccess
199 ; on successful install, show message then start it
200 IntCmp $UpdateExisting 0 0 updated updated
201 MessageBox MB_YESNO|MB_DEFBUTTON1|MB_ICONQUESTION "Privoxy has been installed.${NL}${NL}Start Privoxy now?" /SD IDNO IDYES execprivoxy IDNO done
204 MessageBox MB_YESNO|MB_DEFBUTTON1|MB_ICONEXCLAMATION "Privoxy has been updated.${NL}Don't forget to convert configuration from the 'old*' files!${NL}${NL}Start Privoxy now?" /SD IDNO IDYES execprivoxy IDNO done
207 ; run privoxy after installation
208 SetOutPath "$INSTDIR"
210 Exec "$INSTDIR\privoxy.exe"
215 ; begin uninstall settings/section. The UninstallText line must be before the Section header.
217 UninstallText "This will uninstall Privoxy from your system"
219 SetShellVarContext all ; (Remove from "All Users" Start Menu if possible)
221 ;DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Privoxy.org\Privoxy"
222 DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Privoxy"
224 DeleteRegKey HKEY_CLASSES_ROOT ".action"
225 DeleteRegKey HKEY_CLASSES_ROOT "PrivoxyActionFile"
226 DeleteRegKey HKEY_CLASSES_ROOT ".filter"
227 DeleteRegKey HKEY_CLASSES_ROOT "PrivoxyFilterFile"
229 Delete "$SMSTARTUP\Privoxy.lnk"
231 !insertmacro ClosePrivoxy
233 RMDir /r "$SMPROGRAMS\Privoxy"