Var LatexPath
Var EditorPath
Var PythonPath
+Var ImageMagickPath
Var PathPrefix
Var Answer
Var UserName
Var CreateDesktopIcon
+Var FileAssociation
Var StartmenuFolder
Var ProductRootKey
Var AppPre
!include "LogicLib.nsh"
!include "FileFunc.nsh"
!include "StrFunc.nsh"
-
+!include "TextFunc.nsh"
+!insertmacro LineFind
!include "WordFunc.nsh"
!insertmacro WordReplace
; Set of various macros and functions
!include "LyXUtils.nsh"
+; Use the Abiword macros to help set up associations with the file extension in the Registry.
+; Grabbed from
+; http://abiword.pchasm.org/source/cvs/abiword-cvs/abi/src/pkg/win/setup/NSISv2/abi_util_fileassoc.nsh
+!include "abi_util_fileassoc.nsh"
+
; list with modified files
!include "Updated.nsh"
; delete old registry entries
DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY_OLD}"
- DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY_OLD}"
+ DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
DeleteRegKey HKCR "Applications\lyx.bat"
+ ; remove extension .lyx
+ ${RemoveFileAssociation} "${PRODUCT_EXT}" "${PRODUCT_NAME}"
+ DeleteRegKey HKCR "${PRODUCT_NAME}"
; determine the new name of the install location,
; only when the user has used the default path settings of the previous LyX-version
StrLen $3 $String
Call StrPoint ; search the LaTeXPath for the phrase "${PRODUCT_VERSION_OLD}" (function from LyXUtils.nsh)
${if} $Pointer != "-1" ; if something was found
+
IntOp $Pointer $Pointer - 1 ; jump before the first "\" of "\${PRODUCT_VERSION_OLD}"
StrCpy $String $String "$Pointer" ; $String is now the part before "\${PRODUCT_VERSION_OLD}"
; rename the installation folder by copying LyX files
; delete the old folder
RMDir /r $INSTDIR
StrCpy $INSTDIR $INSTDIR_NEW
- ; read the PATH_PREFIX
- FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" r
+
+ ; set new PATH_PREFIX in the file lyxrc.dist
+ FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" a
FileRead $R1 $PathPrefix
${WordReplace} $PathPrefix "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $PathPrefix
- FileClose $R1
- ; set the PATH_PREFIX according to the new folder
- FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
FileSeek $R1 0 ; set file pointer to the beginning
- FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n' ; overwrite the existing path with the actual one
+ FileWrite $R1 '$PathPrefix' ; overwrite the existing path with the actual one
FileClose $R1
- ${endif}
+
+ ; set the new path to the preferences files for all users
+ Call CheckAppPathPreferences ; Function from LyXUtils.nsh
+
+ ; set new path to ImageMagick
+ ReadRegStr $ImageMagickPath SHCTX "SOFTWARE\Classes\Applications" "AutoRun"
+ ${if} $ImageMagickPath != ""
+ ${WordReplace} $ImageMagickPath "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $ImageMagickPath ; macro from WordFunc.nsh
+ WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" "$ImageMagickPath"
+ ${endif}
+
+ ${endif} ; end ${if} $Pointer != "-1" (if the folder is renamed)
; register LyX
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "${PRODUCT_EXE}"
WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
- ; create start menu entry
+ ; create start menu entry
+ MessageBox MB_OK "$SMPROGRAMS\$StartmenuFolder"
SetOutPath "$INSTDIR\bin"
CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
CreateShortCut "$SMPROGRAMS\$StartmenuFolder\${PRODUCT_NAME}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
SetOutPath "$INSTDIR\bin"
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
${endif}
+
+ ; register the extension .lyx
+ ReadRegStr $FileAssociation HKCR "LyX\shell\open\command" ""
+ ${if} $CreateFileAssociations != ""
+ ${CreateApplicationAssociation} "${PRODUCT_NAME}" "${PRODUCT_NAME}" "$(FileTypeTitle)" "${PRODUCT_EXE}" "${PRODUCT_BAT}"
+ ${CreateFileAssociation} "${PRODUCT_EXT}" "${PRODUCT_NAME}" "${PRODUCT_MIME_TYPE}"
+ ${endif}
; test if Python is installed
; only use an existing python when it is version 2.5 because many Compaq and Dell PC are delivered
FileClose $R1
MessageBox MB_OK|MB_ICONINFORMATION "$(LatexConfigInfo)"
ExecWait '"$INSTDIR\Resources\configLyX.bat"'
- ;Delete "$INSTDIR\Resources\configLyX.bat"
+ Delete "$INSTDIR\Resources\configLyX.bat"
SectionEnd
-# This script contains the following functions:
-#
-# - LaTeXCheck (check installed LaTeX-system), uses:
-# StrPointer
-# StrPoint
-# RevStrPointer
-# RevStrPoint
-#
-# - un.DelAppPathSub and UnAppPreSuff, (delete the folder ~\Documents and Settings\username\Application Data\LyX for all users), uses:
-# un.GetParent
-# un.GetUsers
-# un.StrPoint
-# StrPointer
-# StrPoint
-# UnAppPreSuff
-#
-# - CreateAppPathSub and AppPreSuff, (creates the folder ~\Documents and Settings\username\Application Data\LyX for all users), uses:
-# GetParent
-# GetUsers
-# StrPointer
-# StrPoint
-# UnAppPreSuff
-#
-# - IsUserAdmin (checks if user is admin)
-#
-# - FileCheck (checks if a given file exists)
-#
-# - EditorCheck (check for installed editors)
-#
-#--------------------------
+; This script contains the following functions:
+;
+; - LaTeXCheck (check installed LaTeX-system), uses:
+; StrPointer
+; StrPoint
+; RevStrPointer
+; RevStrPoint
+;
+; - un.DelAppPathSub and UnAppPreSuff, (delete the folder ~\Documents and Settings\username\Application Data\LyX for all users), uses:
+; un.GetParentA
+; un.GetUsers
+; un.StrPoint
+; StrPointer
+; StrPoint
+; UnAppPreSuff
+;
+; - CreateAppPathSub and AppPreSuff, (creates the folder ~\Documents and Settings\username\Application Data\LyX for all users), uses:
+; GetParentA
+; GetUsers
+; StrPointer
+; StrPoint
+; UnAppPreSuff
+;
+; - CheckAppPathPreferences (replaces the old install folder name with the new one in the preferences files)
+; (used by Update installer), uses:
+; ReplaceLineContent
+;
+; - IsUserAdmin (checks if user is admin)
+;
+; - FileCheck (checks if a given file exists)
+;
+; - EditorCheck (check for installed editors)
+;
+;--------------------------
!macro StrPointer FindStr SearchStr Pointer
- # searches for a string/character (SearchStr) in another string (FindStr)
- # and returns the number of the character in the FindStr where the SearchStr was found (Pointer)
- # if nothing was found or the search is impossible the Pointer is set to -1
+ ; searches for a string/character (SearchStr) in another string (FindStr)
+ ; and returns the number of the character in the FindStr where the SearchStr was found (Pointer)
+ ; if nothing was found or the search is impossible the Pointer is set to -1
StrLen $R2 ${SearchStr}
StrLen $R4 ${FindStr}
!macroend
-#--------------------------------
+;--------------------------------
Function StrPoint
!insertmacro StrPointer $String $Search $Pointer
FunctionEnd
-#--------------------------------
+;--------------------------------
!macro RevStrPointer FindStr SearchStr Pointer
- # searches for a string/character (SearchStr) in another string (FindStr) in reverse order
- # and returns the number of the character in the FindStr where the SearchStr was found (Pointer)
- # if nothing was found or the search is impossible the Pointer is set to +1
+ ; searches for a string/character (SearchStr) in another string (FindStr) in reverse order
+ ; and returns the number of the character in the FindStr where the SearchStr was found (Pointer)
+ ; if nothing was found or the search is impossible the Pointer is set to +1
StrLen $R2 ${SearchStr}
StrLen $R4 ${FindStr}
!macroend
-#--------------------------------
+;--------------------------------
Function RevStrPoint
!insertmacro RevStrPointer $String $Search $Pointer
FunctionEnd
-#--------------------------------
+;--------------------------------
!macro AppPreSuff AppPre AppSuff
- # the APPDATA path has always the following structure:
- # C:\Documents and Settings\username\Application Data
- # this macro saves the "C:\Documents and Settings\" substring into the variable "AppPre"
- # and the "Application Data" substring into the variable "AppSuff"
+ ; the APPDATA path has always the following structure:
+ ; C:\Documents and Settings\username\Application Data
+ ; this macro saves the "C:\Documents and Settings\" substring into the variable "AppPre"
+ ; and the "Application Data" substring into the variable "AppSuff"
StrCpy $String "$APPDATA"
StrCpy $Search "\"
!macroend
-#--------------------------------
+;--------------------------------
-Function GetParent
- # deletes a subfolder of the APPDATA path for all users
- # used by the function "un.getUsers"
+Function GetParentA
+ ; deletes a subfolder of the APPDATA path for all users
+ ; used by the function "un.getUsers"
Exch $R0
Push $R1
FunctionEnd
-#--------------------------------
+;--------------------------------
Function GetUsers
- # reads the subfolders of the "Documents and Settings" folder to get a list of the users
+ ; reads the subfolders of the "Documents and Settings" folder to get a list of the users
StrCpy $R3 ""
Push "$PROFILE"
- Call GetParent
+ Call GetParentA
Pop $R2
StrCpy $R2 "$R2"
FindFirst $R0 $R1 "$R2\*"
FunctionEnd
-#--------------------------------
+;--------------------------------
-Function un.GetParent
- # deletes a subfolder of the APPDATA path for all users
- # used by the function "un.getUsers"
+Function un.GetParentA
+ ; deletes a subfolder of the APPDATA path for all users
+ ; used by the function "un.getUsers"
Exch $R0
Push $R1
FunctionEnd
-#--------------------------------
+;--------------------------------
Function un.GetUsers
- # reads the subfolders of the "Documents and Settings" folder to get a list of the users
+ ; reads the subfolders of the "Documents and Settings" folder to get a list of the users
StrCpy $R3 ""
Push "$PROFILE"
- Call un.GetParent
+ Call un.GetParentA
Pop $R2
StrCpy $R2 "$R2"
FindFirst $R0 $R1 "$R2\*"
FunctionEnd
-#--------------------------------
+;--------------------------------
Function un.StrPoint
!insertmacro StrPointer $String $Search $Pointer
FunctionEnd
-#--------------------------------
+;--------------------------------
!macro UnAppPreSuff AppPre AppSuff
- # the APPDATA path has always the following structure:
- # C:\Documents and Settings\username\Application Data
- # this macro saves the "C:\Documents and Settings\" substring into the variable "AppPre"
- # and the "Application Data" substring into the variable "AppSuff"
+ ; the APPDATA path has always the following structure:
+ ; C:\Documents and Settings\username\Application Data
+ ; this macro saves the "C:\Documents and Settings\" substring into the variable "AppPre"
+ ; and the "Application Data" substring into the variable "AppSuff"
StrCpy $String "$APPDATA"
StrCpy $Search "\"
!macroend
-#--------------------------------
+;--------------------------------
Function un.DelAppPathSub
- # deletes a subfolder of the APPDATA path for all users
+ ; deletes a subfolder of the APPDATA path for all users
- # get list of all users
+ ; get list of all users
Push $R0
Push $R1
Push $R2
Pop $R1
Pop $R0
- # the usernames in the list of all users is separated by "|"
+ ; the usernames in the list of all users is separated by "|"
loop:
StrCpy $String "$UserList"
StrCpy $Search "|"
StrCpy $0 $UserList $Pointer ; $0 contains now the username
IntOp $Pointer $Pointer + 1 ; jump after the "|"
StrCpy $UserList $UserList "" $Pointer ; cut off the first username in the list
- # generate the string for the current user
- # AppPre and AppSuff are generated in the macro "AppPreSuff"
+ ; generate the string for the current user
+ ; AppPre and AppSuff are generated in the macro "AppPreSuff"
StrCpy $AppPath "$AppPre\$0\$AppSuff\${PRODUCT_SUBFOLDER}"
RMDir /r $AppPath ; delete the folder
Goto loop
FunctionEnd
-#--------------------------------
+;--------------------------------
Function CreateAppPathSub
- # creates a subfolder of the APPDATA path for all users
+ ; creates a subfolder of the APPDATA path for all users
- # get folder names
+ ; get folder names
!insertmacro AppPreSuff $AppPre $AppSuff
- # get list of all users
+ ; get list of all users
Push $R0
Push $R1
Push $R2
Pop $R1
Pop $R0
- # the usernames in the list of all users is separated by "|"
+ ; the usernames in the list of all users is separated by "|"
loop:
StrCpy $String "$UserList"
StrCpy $Search "|"
Call StrPoint ; search for the "|"
- StrCmp $Pointer "-1" ready
+ StrCmp $Pointer "-1" ready ; the loop is finished when no "|" could be found
StrCpy $0 $UserList $Pointer ; $0 contains now the username
IntOp $Pointer $Pointer + 1 ; jump after the "|"
StrCpy $UserList $UserList "" $Pointer ; cut off the first username in the list
- # generate the string for the current user
- # AppPre and AppSuff are generated in the macro "AppPreSuff"
+ ; generate the string for the current user
+ ; AppPre and AppSuff are generated in the macro "AppPreSuff"
StrCpy $AppPath "$AppPre\$0\$AppSuff\${PRODUCT_SUBFOLDER}"
CreateDirectory $AppPath ; create the folder
CopyFiles "$INSTDIR\Resources\session" "$AppPath"
Goto loop
ready:
+ ; now do the same for the last user name
StrCpy $0 $UserList
StrCpy $AppPath "$AppPre\$0\$AppSuff\${PRODUCT_SUBFOLDER}"
CreateDirectory $AppPath ; create the folder
FunctionEnd
-#--------------------------------
+;--------------------------------
+
+Function ReplaceLineContent
+ ; replaces "${PRODUCT_VERSION_OLD}" with "LyX ${PRODUCT_VERSION}"
+
+ ${WordReplace} '$R9' "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" '$R9' ; macro from WordFunc.nsh
+ Push $0
+
+FunctionEnd
+
+;--------------------------------
+
+Function CheckAppPathPreferences
+ ; modify the preferences file for all users
+
+ ; get folder names
+ !insertmacro AppPreSuff $AppPre $AppSuff
+
+ ; get list of all users
+ Push $R0
+ Push $R1
+ Push $R2
+ Push $R3
+ Call GetUsers
+ StrCpy $UserList $R3 "" 1 ; cut off the "|" at the end of the list
+ Pop $R3
+ Pop $R2
+ Pop $R1
+ Pop $R0
+
+ ; the usernames in the list of all users is separated by "|"
+ loop:
+ StrCpy $String "$UserList"
+ StrCpy $Search "|"
+ Call StrPoint ; search for the "|"
+ StrCmp $Pointer "-1" ready ; the loop is finished when no "|" could be found
+ StrCpy $0 $UserList $Pointer ; $0 contains now the username
+ IntOp $Pointer $Pointer + 1 ; jump after the "|"
+ StrCpy $UserList $UserList "" $Pointer ; cut off the first username in the list
+ ; generate the string for the current user
+ ; AppPre and AppSuff are generated in the macro "AppPreSuff"
+ StrCpy $AppPath "$AppPre\$0\$AppSuff\${PRODUCT_SUBFOLDER}"
+ ; read the preferences file to test if it exists
+ FileOpen $R1 "$AppPath\preferences" r
+ IfErrors doneA
+ FileClose $R1
+ ; search for "${PRODUCT_VERSION_OLD}" and replace it with "LyX ${PRODUCT_VERSION}"
+ ${LineFind} "$AppPath\preferences" "" "1:-1" "ReplaceLineContent" ; macro from TextFunc.nsh
+ doneA:
+ Goto loop
+ ready:
+ ; now do the same for the last user name
+ StrCpy $0 $UserList
+ StrCpy $AppPath "$AppPre\$0\$AppSuff\${PRODUCT_SUBFOLDER}"
+ FileOpen $R1 "$AppPath\preferences" r
+ IfErrors doneB
+ FileClose $R1
+ ${LineFind} "$AppPath\preferences" "" "1:-1" "ReplaceLineContent"
+ doneB:
+
+FunctionEnd
+
+;--------------------------------
!macro IsUserAdmin Result Name
!macroend
-#--------------------------------
+;--------------------------------
!macro FileCheck Result FileName FilePath
- # checks if a file exists, returns "True" or "False"
+ ; checks if a file exists, returns "True" or "False"
Push $0
Push $1
!macroend
-#------------------------------------------
+;------------------------------------------
Function LaTeXCheck
- # searches the string "$Search" in the string "$String" and extracts the path around it
- # the extracted path is checked if the file "latex.exe" is in it
+ ; searches the string "$Search" in the string "$String" and extracts the path around it
+ ; the extracted path is checked if the file "latex.exe" is in it
StartCheck:
StrLen $3 $String
StrCpy $String $String $Pointer
${endif}
StrCpy $LatexPath "$LatexPath$String"
- # check if the latex.exe exists in the $LatexPath folder
+ ; check if the latex.exe exists in the $LatexPath folder
!insertmacro FileCheck $5 "latex.exe" "$LatexPath"
${if} $5 == "False" ; delete the entry with the wrong path to the latex.exe and try again
StrCpy $LatexPath ""
FunctionEnd
-#------------------------------------------
+;------------------------------------------
Function EditorCheck
- # test if an editor with syntax-highlighting for LaTeX-files is installed
- # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
+ ; test if an editor with syntax-highlighting for LaTeX-files is installed
+ ; (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
StrCpy $EditorPath ""
StrCpy $0 ""
- # check for jEdit
+ ; check for jEdit
ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
${if} $EditorPath != ""
StrCpy $EditorPath $EditorPath -1 ; remove "\" from the end of the string
${endif}
- # check for PSPad
+ ; check for PSPad
StrCpy $0 ""
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
${if} $0 != ""
StrCpy $0 $0 -1
StrCpy $EditorPath "$EditorPath;$0"
${endif}
- # check for WinShell
+ ; check for WinShell
StrCpy $0 ""
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
${if} $0 != ""
StrCpy $0 $0 -1
StrCpy $EditorPath "$EditorPath;$0"
${endif}
- # check for ConTEXT
+ ; check for ConTEXT
StrCpy $0 ""
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ConTEXTEditor_is1" "InstallLocation"
${if} $0 != ""
StrCpy $0 $0 -1
StrCpy $EditorPath "$EditorPath;$0"
${endif}
- # check for Crimson Editor
+ ; check for Crimson Editor
StrCpy $0 ""
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Crimson Editor" "UninstallString"
${if} $0 != ""
StrCpy $0 $0 -14 ; remove "\uninstall.exe"
StrCpy $EditorPath "$EditorPath;$0"
${endif}
- # check for Vim 6.x
+ ; check for Vim 6.x
StrCpy $0 ""
ReadRegStr $0 HKLM "Software\Classes\Applications\gvim.exe\shell\edit\command" ""
${if} $0 != ""
StrCpy $0 $0 -13 ; remove "gvim.exe "%1""
StrCpy $EditorPath "$EditorPath;$0"
${endif}
- # check for Vim 7.0
+ ; check for Vim 7.0
StrCpy $0 ""
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Vim 7.0" "UninstallString"
${if} $0 != ""
StrCpy $0 $0 -18 ; remove "\uninstall-gui.exe"
StrCpy $EditorPath "$EditorPath;$0"
${endif}
- # check for TeXnicCenter
+ ; check for TeXnicCenter
StrCpy $0 ""
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "Inno Setup: App Path"
${if} $0 != ""
StrCpy $EditorPath "$EditorPath;$0"
${endif}
- # check for LaTeXEditor
+ ; check for LaTeXEditor
StrCpy $0 ""
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LaTeX Editor" "InstallLocation"
${if} $0 != ""
StrCpy $EditorPath "$EditorPath;$0"
${endif}
- # check for WinEdt
+ ; check for WinEdt
StrCpy $0 ""
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt_is1" "InstallLocation"
${if} $0 != ""
StrCpy $0 $0 -1
StrCpy $EditorPath "$EditorPath;$0"
${endif}
- # check for LEd
+ ; check for LEd
StrCpy $0 ""
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LEd_is1" "InstallLocation"
${if} $0 != ""
StrCpy $0 $0 -1
StrCpy $EditorPath "$EditorPath;$0"
${endif}
- # check for WinTeX
+ ; check for WinTeX
StrCpy $0 ""
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinTeX XP" "DisplayIcon"
${if} $0 != ""