;======================================================================================== ;Please Note:- ; - When Amending please increment the version ; - Please add all changes to the Version Notes ;========================================================================================= ; Script :- Zebra OPC Server Installer ; Version :- 1.0.1.4b ; Author :- Carl Harper ; Comments :- Files which will be installed into the dir ; +- Zebra OPC Server ; +---ZebraConfigurator.exe ; +---ZebraServer.exe ** ; +---database.mdb ; +---Database.src ; ; Startmenu Shortcuts ; +- Zebra OPC Server ; +--Zebra OPC Server Configurator ; +- Uninstall.exe ; ; Desktop Shortcuts ; +- Zebra OPC Server configurator ;========================================================================================== ;========================================================================================== ;Version 1.0.1.4c ; - Add Detection code to detect if MDAC 2.7 executable is not in the tools dir ; - if not there will prompt user to select ; ;========================================================================================== ;========================================================================================== ;Version 1.0.1.4b ; - Added Detection Code for MDAC 2.7 ; - Code checks registry key "FullInstallVer" ; - Parses Registry Key to receive the first the char i.e "2.7" ; - Compares the String with the value in $R1 with 2.7 ;; - If they equal goto Noabort, and Carry on Installation ; - If they are not equal goto AbortYes ; - Display Messagbox prompter user if they wish to install 2.7 ; - if Yes ; - Start MDAC Installation ; - Abort Unintaller ; - If no Carry on Installation ;========================================================================================== ;========================================================================================== ;Version 1.0.1.4a ; - Added Files Readme.txt ; - Added Files Usermanual.pdf ; - Added Uninstall for both files ;========================================================================================== ;========================================================================================== ;Version 1.0.1.4 ; - Added New Registry Key ; -HKLM\SOFTWARE\Zebra\Zebra ZPLII OPC Data Server and Zebra ZPL II OPC Event Server\Configuration' ; "UseEventListener" 1 ; - Removed New Registry Key ;========================================================================================== ;========================================================================================== ;Version 1.0.1.3 ; - Fixed Inter Op Crash during Uninstall ;========================================================================================== ;========================================================================================== ;Version 1.0.1.3 ; - Changed installation for Beta 1 Release ; - Removed templates! ; - Added Empty Database to installation! ;========================================================================================== ;========================================================================================== ;Version 1.0.0.1 ; - Tided up installation - Removed ICON File! ; - Using 1.0.0.2 of the module Runtime exe ; - Changed the Control/Panel icon so it no uses the configurator icon ; - Changed the Database(from Database.mdb to ;========================================================================================== ;========================================================================================== ;Version 1.0.0 ; - Found Issue with the uninstall it seems that unregistration was taking ; - to much time, Added Sleep statement which fixes the problem ; - Added Possibility so that the user can launch the configurator after the install ;========================================================================================== ;========================================================================================== ;Version 0.1.1 ; - Added File Copying and registering ; - Added removal of files and unregistering ;========================================================================================== OutFile "Install.exe" InstallDir "$PROGRAMFILES\ICONICS UK LTD\Zebra OPC Server" !ifndef CLASSIC_UI ;Include Modern UI Macro's !include "System.nsh" ;Modern UI Configuration !define MUI_PRODUCT "Zebra OPC Server" !define MUI_VERSION "Beta Release 1" !define MUI_NAME "Zebra OPC Server(Beta Release 1)" ;Installer name !define MUI_WELCOMEPAGE !define MUI_LICENSEPAGE !define MUI_DIRECTORYPAGE !define MUI_COMPONENTSPAGE !define MUI_FINISHPAGE !define MUI_FINISHPAGE_RUN "$INSTDIR\ZebraConfigurator.exe" !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Readme.txt" !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED !define MUI_FINISHPAGE_RUN_NOTCHECKED !define MUI_ABORTWARNING !define MUI_UNINSTALLER !define MUI_UNCONFIRMPAGE !define MUI_SPECIALBITMAP ".\misc\modern-wizard.bmp" !define MUI_UI "${NSISDIR}\Contrib\UIs\modern2.exe" LicenseData .\misc\license.txt ;Languages ;Modern UI System !insertmacro MUI_SYSTEM ;=================================================================================================== !define MUI_TEXT_WELCOME_INFO_TEXT "This wizard will guide you through the installation of the Zebra OPC Server. Please close down all running applications\r\n\r\n\r\n" !insertmacro MUI_LANGUAGE "English" !endif Function .onInit ReadRegStr $R0 HKLM "Software\Microsoft\DataAccess" "FullInstallVer" ;Get the Version of Mdac ;MessageBox MB_OK $R0 StrCpy $R1 $R0 3 ;Parses the String to get the first 3 characther ;MessageBox MB_OK $R1 StrCmp $R1 "2.7" NoAbort AbortYes ;if $R1 = 2.7 goto Noabort to carry on the installation ;if $R1 <> 2.7 goto AbortYes to carry to prompt the user for MDAC Installation AbortYes: ; AbortYes is selected IfFileExists "$EXEDIR\Tools\mdac_typ.exe" FileExist FileNotExist FileNotExist: MessageBox MB_YESNO|MB_ICONQUESTION "Microsoft MDAC 2.7 has not been located for installation, Please Note without MDAC 2.7 the OPC Server might not perform correctly$\n\ Do you wish to continue with the Zebra OPC Server Installation" IDYES NoAbort IDNO AbortInstall AbortInstall: Abort FileExist: MessageBox MB_YESNO|MB_ICONQUESTION "Microsoft MDAC 2.7 has not been detected on your system, Do you wish to install MDAC 2.7" IDYES YesInstall IDNO NoAbort ;Will prompt a Messagebox if the user wants to install MDAC 2.7 ; Yes is clicked goto YesInstall ; No is Clicked goto NoAbort: YesInstall: exec "$EXEDIR\Tools\mdac_typ.exe" Abort ; causes installer to quit. NoAbort: FunctionEnd ;Installer Sections Section "Zebra OPC Server Core Files" SecCopyUI SectionIn 1 RO ;The Below entries are used to add support for the Add/Remove Program Dialog SetOutPath "$INSTDIR" WriteRegStr HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\IULZebraOPC "DisplayName" "Zebra OPC Server(Remove Only)" WriteRegStr HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\IULZebraOPC "UninstallString" '"$INSTDIR\uninstall.exe' WriteRegStr HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\IULZebraOPC "DisplayIcon" '"$INSTDIR\ZebraConfigurator.exe"' File ".\InstallFiles\Database.mdb" File ".\InstallFiles\ZebraRuntime.exe" File ".\InstallFiles\ZebraConfigurator.exe" File ".\InstallFiles\ZebraConfigurator.src" File ".\InstallFiles\Readme.txt" File ".\InstallFiles\ZebraOPCServerUserManual.pdf" WriteRegStr HKLM 'SOFTWARE\Zebra\Zebra ZPLII OPC Data Server and Zebra ZPL II OPC Event Server\Configuration' "FileName" "$INSTDIR\Database.mdb" WriteRegDWORD HKLM 'SOFTWARE\Zebra\Zebra ZPLII OPC Data Server and Zebra ZPL II OPC Event Server\Configuration' "UseEventListener" 1 Exec '"$INSTDIR\ZebraRuntime.exe" /regserver' ;====================================================================================== WriteUninstaller "$INSTDIR\uninstall.exe" SectionEnd ;Create the Start Menu ShortsCuts subSection "Start Menu + Desktop Shortcuts" SecMenu Section "Start Menu Shortcuts" SecMenuSM CreateDirectory "$SMPROGRAMS\Zebra OPC Server" CreateDirectory "$SMPROGRAMS\Zebra OPC Server\Help" CreateShortCut "$SMPROGRAMS\Zebra OPC Server\Help\ZebraOPCServerUserManual.lnk""$INSTDIR\ZebraOPCServerUserManual.pdf" "" "$INSTDIR\ZebraOPCServerUserManual.pdf" 0 CreateShortCut "$SMPROGRAMS\Zebra OPC Server\Zebra OPC Server Configurator.lnk" "$INSTDIR\ZebraConfigurator.exe" "" "$INSTDIR\ZebraConfigurator.exe" 0 CreateShortCut "$SMPROGRAMS\Zebra OPC Server\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 SectionEnd Section "Zebra OPC Server Shortcut" SecMenuDesk2 CreateShortCut "$DESKTOP\Zebra OPC Server Configurator.lnk" "$INSTDIR\ZebraConfigurator.exe" "" "$INSTDIR\ZebraConfigurator.exe" 0 sectionend subsectionend !ifndef CLASSIC_UI ;-------------------------------- ;Descriptions !insertmacro MUI_FUNCTIONS_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecCopyUI} "Installs core files required to use the Zebra OPC Server" !insertmacro MUI_DESCRIPTION_TEXT ${SecMenuSM} "Installs Start Menu Shortcuts" !insertmacro MUI_DESCRIPTION_TEXT ${SecMenu} "Installs Start Menu and Desktop Shortcuts" !insertmacro MUI_DESCRIPTION_TEXT ${SecMenuDesk2} "Installs Zebra OPC Server Configurator shortcut to the desktop" !insertmacro MUI_FUNCTIONS_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section Section "Uninstall" ; Must do this here so that it will give the unreg some time to finsh Exec '"$INSTDIR\ZebraRuntime.exe" /unregserver' Delete "$INSTDIR\Database.mdb" Delete "$INSTDIR\ZebraConfigurator.exe" Delete "$INSTDIR\ZebraConfigurator.src" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\IULZebraOPC" DeleteRegValue HKLM "SOFTWARE\Zebra\Zebra ZPLII OPC Data Server and Zebra ZPL II OPC Event Server\Configuration" "FileName" DeleteRegValue HKLM "SOFTWARE\Zebra\Zebra ZPLII OPC Data Server and Zebra ZPL II OPC Event Server\Configuration" "UseEventListener" DeleteRegKey HKLM "Software\Zebra" sleep 500 ;This is needed so the unregistering process can be acheived! Delete "$SMPROGRAMS\Zebra OPC Server\*.*" Delete "$SMPROGRAMS\Zebra OPC Server\Help\*.*" Delete "$DESKTOP\Zebra OPC Server Configurator.lnk" Delete "$INSTDIR\ZebraRuntime.exe" Delete "$INSTDIR\Uninstall.exe" Delete "$INSTDIR\Readme.txt" Delete "$INSTDIR\ZebraOPCServerUserManual.pdf" RMDir "$SMPROGRAMS\Zebra OPC Server\Help" RMDir "$SMPROGRAMS\Zebra OPC Server" RMDir "$INSTDIR" Push "$INSTDIR" Call un.GetParent Pop $R0 RMDIR $R0 ;''Delete the "Root Dir" if empty! !insertmacro MUI_UNFINISHHEADER SectionEnd Function un.GetParent Exch $R0 ; old $R0 is on top of stack Push $R1 Push $R2 StrCpy $R1 -1 loop: StrCpy $R2 $R0 1 $R1 StrCmp $R2 "" exit StrCmp $R2 "\" exit IntOp $R1 $R1 - 1 Goto loop exit: StrCpy $R0 $R0 $R1 Pop $R2 Pop $R1 Exch $R0 ; put $R0 on top of stack, restore $R0 to original value FunctionEnd