out_moya.nsi 5.34 KB
; NSIS script - ONLY for use with AutoPublish/AutoUpdate system

; //keitsi



;--------------------------------

;Include Modern UI



  !include "MUI.nsh"



;--------------------------------

;Configuration

  SetCompressor lzma



  Name "MoyaAdminUI moya v1_00_06"

  ; DO NOT CHANGE OutFile "installer_temp.exe" !!! AutoPublish requires this.

  ; AutoPublish will move the installer according to autopublish.xml file.

  OutFile "installer_temp.exe"

  

  ;Folder selection page

  ; InstallDir "$PROGRAMFILES\MoyaAdminUI_moya"

  

  ShowInstDetails show



;--------------------------------

;Interface Settings



  !define MUI_ABORTWARNING



;--------------------------------

;Pages



  ; !insertmacro MUI_PAGE_LICENSE "license.txt"

  !insertmacro MUI_PAGE_COMPONENTS

  !insertmacro MUI_PAGE_DIRECTORY

  !insertmacro MUI_PAGE_INSTFILES



  ; !define MUI_FINISHPAGE_RUN $INSTDIR\MoyaAdminUI.exe

  !insertmacro MUI_PAGE_FINISH



  !insertmacro MUI_UNPAGE_CONFIRM

  !insertmacro MUI_UNPAGE_INSTFILES



;--------------------------------

;Languages

 

  !insertmacro MUI_LANGUAGE "English"



;--------------------------------

;Installer Sections



Function GetDotNet

  IfFileExists "$WINDIR\Microsoft.NET\Framework\v2.0.50727\installUtil.exe" NextStep

  MessageBox MB_OK|MB_ICONEXCLAMATION "You must have the Microsoft .NET Framework 2.0 Installed to use this application. $\n$\nClick 'Open' in the following file dialog to download and run the Microsoft .NET Framework Installer..."

  ExecShell Open "http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=0856eacb-4362-4b0d-8edd-aab15c5e04f5&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f5%2f6%2f7%2f567758a3-759e-473e-bf8f-52154438565a%2fdotnetfx.exe" SW_SHOWNORMAL

  Quit

NextStep:

FunctionEnd



Function .onInit

; Uber users are so uber that they do not need checks ;)

;  Call GetDotNet

  Call DetectInstallDir

FunctionEnd



Function DetectInstallDir

  ;Try to get install folder from obsoleted registry key first, if available

  ClearErrors

  ReadRegStr $INSTDIR HKCU "Software\MoyaAdminUI" ""

  IfErrors 0 instdirfound

  ClearErrors

  ; No obsoleted regkey present, try to read the correct one

  ReadRegStr $INSTDIR HKCU "Software\MoyaAdminUI_moya" ""

  IfErrors 0 instdirfound

  ClearErrors

  ; No installation dir regkey present at all - use default installation directory.

  StrCpy $INSTDIR "$PROGRAMFILES\MoyaAdminUI_moya"

instdirfound:

FunctionEnd



Function .onInstSuccess

	Exec '"$INSTDIR\MoyaAdminUI.exe"'

FunctionEnd



Function WaitProgramClose

	IfFileExists "$INSTDIR\MoyaAdminUI.exe" loop NotInstalled

loop:

	ClearErrors

	Delete "$INSTDIR\MoyaAdminUI.exe"

	${If} ${Errors}

		; Delete failed - means the program is still running. Sleep 2 seconds and retry.

		Sleep 3000

		ClearErrors

		Delete "$INSTDIR\MoyaAdminUI.exe"

		${If} ${Errors}

			MessageBox MB_OK "Program MoyaAdminUI.exe didn't close in 2 seconds. Automatic update can't continue before it's closed. Please close the program manually and hit OK to retry."

			goto loop

		${EndIf}

	${EndIf}

NotInstalled:

FunctionEnd



Section "!MoyaAdminUI moya stable v1_00_06" SecMain

  SetShellVarContext current

  SetOutPath "$INSTDIR"

  Call WaitProgramClose

  ; SetOverwrite Off

  

  SetOverwrite On

  File /oname=autoupdate.xml "D:\Devel\proj\MoyaAdmin\MoyaAdminUI\MoyaAdminUI\bin\Debug\autoupdate.moya.xml"

  File /oname=MoyaAdminUI.exe "D:\Devel\proj\MoyaAdmin\MoyaAdminUI\MoyaAdminUI\bin\Debug\MoyaAdminUI.exe"

  File autoupdate.crt



  ; this line will be replicated for every non-default existing assembly

  ; that is referenced to the main project.


  File "D:\Devel\proj\MoyaAdmin\MoyaAdminUI\MoyaAdminUI\bin\Debug\MoyaAdminUI.pdb"



  ; Write install path to registry (projectname_customer_versiongroup)

  WriteRegStr HKCU "Software\MoyaAdminUI_moya" "" $INSTDIR

  ; Remove obsoleted registry key on install

  DeleteRegKey HKCU "Software\MoyaAdminUI"



  ;Create uninstaller

  WriteUninstaller "$INSTDIR\Uninstall.exe"



  ;Create shortcuts

  CreateDirectory "$SMPROGRAMS\MoyaAdminUI moya"

  CreateShortCut "$SMPROGRAMS\MoyaAdminUI moya\MoyaAdminUI.lnk" "$INSTDIR\MoyaAdminUI.exe"

  CreateShortCut "$SMPROGRAMS\MoyaAdminUI moya\Uninstall MoyaAdminUI.lnk" "$INSTDIR\Uninstall.exe"

  

  ; Remove shortcuts from old shortcut naming scheme path, if any

  SetShellVarContext all

  Delete "$SMPROGRAMS\MoyaAdminUI\MoyaAdminUI.lnk"

  Delete "$SMPROGRAMS\MoyaAdminUI\Uninstall MoyaAdminUI.lnk"

  RMDir "$SMPROGRAMS\MoyaAdminUI"

  SetShellVarContext current

  Delete "$SMPROGRAMS\MoyaAdminUI\MoyaAdminUI.lnk"

  Delete "$SMPROGRAMS\MoyaAdminUI\Uninstall MoyaAdminUI.lnk"

  RMDir "$SMPROGRAMS\MoyaAdminUI"

SectionEnd



;--------------------------------

;Descriptions



  LangString DESC_SecMain ${LANG_ENGLISH} "Base (required)"



;--------------------------------

;Uninstaller Section



Section "Uninstall"



  Delete "$SMPROGRAMS\MoyaAdminUI moya\*"

  RMDir "$SMPROGRAMS\MoyaAdminUI moya"

  Delete "$INSTDIR\MoyaAdminUI.exe"

  Delete "$INSTDIR\autoupdate.xml"

  Delete "$INSTDIR\autoupdate.crt"



  ; this line will be replicated for every non-default existing assembly

  ; that is referenced to the main project.


  Delete "$INSTDIR\D:\Devel\proj\MoyaAdmin\MoyaAdminUI\MoyaAdminUI\bin\Debug\MoyaAdminUI.pdb"



  Delete "$INSTDIR\Uninstall.exe"



  RMDir "$INSTDIR"

  

SectionEnd