lyx_mirror/development/Win32/packaging/installer/include/windows.nsh
Joost Verburg a7594d6ca8 * Improved multi-user installation. It is now easier to have both a system as well as a local version of LyX installed.
* Installation for all users is the default for Power Users and Administrators
* For silent installation, it is possible to use the /AllUsers or /CurrentUser command line parameter to choose for which users you want to install
* Updated list of supported languages. The "red" languages from http://www.lyx.org/devel/i18n.php have been removed.
* Language and dictionary names are no longer in English but are translated in the language itself
* One single list with language names, ISO codes and identifiers
* Both the installer and uninstaller automatically detect the user interface language
* Added more space in the user interface for translated texts
* Added all Python encoding files so there will be no problems with future Python scripts

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@15200 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-02 17:21:20 +00:00

185 lines
3.4 KiB
Plaintext

/*
Checks for Windows version
*/
;--------------------------------
;Macros
!macro CheckPrivileges
Push $R0
UserInfo::GetAccountType
Pop $R0
${if} $R0 == "Admin"
StrCpy $AdminOrPowerUser ${TRUE}
${elseif} $R0 == "Power"
StrCpy $AdminOrPowerUser ${TRUE}
${else}
StrCpy $AdminOrPowerUser ${FALSE}
${endif}
Pop $R0
!macroend
!macro CommandLineParameter UNINSTALL
Exch $R0
Push $R1
Push $R2
StrLen $R1 $R0
Push $CMDLINE
Push $R0
Call ${UNINSTALL}StrStr
Pop $R2
StrCpy $R2 $R2 $R1
${if} $R2 == $R0
StrCpy $R0 ${TRUE}
${else}
StrCpy $R0 ${FALSE}
${endif}
Push $R2
Push $R1
Exch $R0
!macroend
;--------------------------------
;Functions
Function CheckPrivileges
!insertmacro CheckPrivileges
FunctionEnd
Function un.CheckPrivileges
!insertmacro CheckPrivileges
FunctionEnd
Function CommandLineParameter
!insertmacro CommandLineParameter ""
FunctionEnd
Function un.CommandLineParameter
!insertmacro CommandLineParameter un.
FunctionEnd
Function CheckWindows
Push $R0
Push $R1
;Check for Windows NT 5.0 or later (2000, XP, 2003 etc.)
ReadRegStr $R0 HKLM "Software\Microsoft\Windows NT\CurrentVersion" "CurrentVersion"
${VersionCompare} $R0 "5.0" $R1
${if} $R1 == "2"
MessageBox MB_OK|MB_ICONSTOP "${APP_NAME} ${APP_VERSION} only supports Windows 2000, XP, 2003 and later."
Quit
${endif}
Pop $R1
Pop $R0
FunctionEnd
Function UpdatePathEnvironment
Push $R0
Push $R1
;Updates the path environment variable of the instaler process to the latest system value
ReadRegStr $R0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path
ReadRegStr $R1 HKCU "Environment" Path
System::Call 'kernel32::SetEnvironmentVariableA(t, t) i("Path", "$R0;$R1").r0'
Pop $R1
Pop $R0
FunctionEnd
Function InitInstaller
Push $R0
Push "/CurrentUser"
Call CommandLineParameter
Pop $CurrentUserInstall
${if} $CurrentUserInstall == ${TRUE}
SetShellVarContext current
${else}
${if} $AdminOrPowerUser == ${TRUE}
SetShellVarContext all
${else}
;Display an error when the /AllUsers command line parameter is used
;by a user without Administrator or Power User priviledges
Push "/AllUsers"
Call CommandLineParameter
Pop $R0
${if} $R0 == ${TRUE}
MessageBox MB_OK|MB_ICONSTOP "You need Administrator or Power User privileges to install ${APP_NAME} for all users."
Quit
${endif}
SetShellVarContext current
${endif}
${endif}
${if} ${silent}
Call InitUser
${endif}
Pop $R0
FunctionEnd
Function un.InitUnInstaller
;Set the correct shell context depending on whether LyX has been installed
;for the current user or all users
Push "/CurrentUser"
Call un.CommandLineParameter
Pop $CurrentUserInstall
${if} $CurrentUserInstall == ${TRUE}
SetShellVarContext current
${else}
${if} $AdminOrPowerUser == ${FALSE}
MessageBox MB_OK|MB_ICONSTOP "${APP_NAME} has been installed for all users. Therefore you need Administrator or Power User privileges to uninstall."
Quit
${else}
SetShellVarContext all
${endif}
${endif}
FunctionEnd