;######################################################################################################################################### ; Define your application name !define APPNAME "PGA1000 Engineering Window" !define APPNAMEANDVERSION "1.0.0" !define PRODUCT_WEB_SITE "Http:\\www.alliedtelesyn.com" !define PRODUCT_PUBLISHER "Allied Telesyn Asia" !define MainATIfolder "PGA Testsuite" !define MicrosoftAddRemove "Software\Microsoft\Windows\CurrentVersion\Uninstall" !define SoftwareHKLMLocation "Software\ATA\PGA" !define INSTALLFROMFOLDER "vbconvert";"Installer\EngWin\" !define OUTPUTFILE "PGA Program\installer\PGA1000 EngWin.exe" !define SHORTCUTLINK "EngWin.exe" !define NEWVERSION "1.0.0" !define ABORTWARNING "A previous version of ${APPNAME} was found. It is recommended that you uninstall it first.$\n$\n Do you want to do that now?" !define FINDWINDOWAPP "PGA1000 ENgWin Uninstall" ;######################################################################################################################################### ; Use compression format - LZMA has the highest compession ratio SetCompressor LZMA ;######################################################################################################################################### ;Include Modern UI !include "MUI.nsh" !define MUI_UI "${NSISDIR}\Contrib\UIs\modern.exe" !define MUI_EXEC "setup.exe" !define MUI_PRODUCT "vbproduct" !define MUI_VERSION "" ;######################################################################################################################################### !define VBFILESDIR "."; !include "${NSISDIR}\Contrib\Modern UI\System.nsh" !include "${NSISDIR}\Include\upgradeDll.nsh" !include "${NSISDIR}\Include\sharedDll.nsh" !include "${NSISDIR}\Include\installVB.nsh" ;######################################################################################################################################### ; Show install/uninstall details ;ShowInstDetails show ;ShowUninstDetails show ;######################################################################################################################################### ;General ; OutFile ".\${MUI_EXEC}" ;Name and file Name "${APPNAME}" OutFile "C:\${OUTPUTFILE}" ;Default installation folder InstallDir "$PROGRAMFILES\AETE\${APPNAME}" ;Get installation folder from registry if available InstallDirRegKey HKLM "${SoftwareHKLMLocation}\${APPNAME}" "" ;######################################################################################################################################### ;Variables Var MUI_TEMP Var STARTMENU_FOLDER ;######################################################################################################################################### ;Modern UI Configuration !define MUI_WELCOMEPAGE !define MUI_COMPONENTSPAGE !define MUI_DIRECTORYPAGE !define MUI_FINISHPAGE !define MUI_ABORTWARNING !define MUI_UNINSTALLER !define MUI_UNCONFIRMPAGE ;######################################################################################################################################### ;Check if there is any pervious installed application Function .onInit ;Section RetriveVersion Push "${NEWVERSION}" ReadRegStr $R0 HKLM "${MicrosoftAddRemove}\${APPNAME}" "DisplayVersion" Push "$R0" Call CompareVersions Pop $R0 FunctionEnd ;######################################################################################################################################### ;Pages !insertmacro MUI_PAGE_DIRECTORY ;Start Menu Folder Page Configuration !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM" !define MUI_STARTMENUPAGE_REGISTRY_KEY "${SoftwareHKLMLocation}\${APPNAME}" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES ;######################################################################################################################################### ;Languages !insertmacro MUI_LANGUAGE "English" ;######################################################################################################################################### ; CompareVersions ; input: ; top of stack = existing version ; top of stack-1 = needed version ; output: ; top of stack = 1 if current version => neded version, else 0 ; version is a string in format "xx.xx.xx.xx" (number of interger sections ; can be different in needed and existing versions) Function CompareVersions ; stack: existing ver | needed ver Exch $R0 Exch Exch $R1 ; stack: $R1|$R0 Push $R1 Push $R0 ; stack: e|n|$R1|$R0 ClearErrors loop: IfErrors VersionNotFound Strcmp $R0 "" VersionTestEnd Call ParseVersion Pop $R0 Exch Call ParseVersion Pop $R1 Exch IntCmp $R1 $R0 +1 VersionOk VersionNotFound Pop $R0 Push $R0 goto loop VersionTestEnd: Pop $R0 Pop $R1 Push $R1 Push $R0 StrCmp $R0 $R1 VersionOk VersionNotFound VersionNotFound: StrCpy $R0 "0" Goto end VersionOk: StrCpy $R0 "1" ReadRegstr $1 HKLM "${MicrosoftAddRemove}\${APPNAME}" "UninstallString" MessageBox MB_YESNO|MB_ICONQUESTION "${ABORTWARNING}"IDNO UninstallMSI_nomsi IDYES UninstallMSI_yesmsi UninstallMSI_yesmsi: Execwait "$1 /S" sleep 500 loopa: FindWindow $0 "" "${FINDWINDOWAPP}" IsWindow $0 0 MSGBOX Goto loopa UninstallMSI_nomsi: quit MSGBOX: sleep 500 loopb: FindWindow $0 "" "${FINDWINDOWAPP}" IsWindow $0 0 done Goto loopb done: MessageBox MB_OK|MB_ICONINFORMATION "Click OK to continue upgrading your version of ${APPNAME}" Goto end end: ; stack: e|n|$R1|$R0 Exch $R0 Pop $R0 Exch $R0 ; stack: res|$R1|$R0 Exch ; stack: $R1|res|$R0 Pop $R1 ; stack: res|$R0 Exch Pop $R0 ; stack: res FunctionEnd ;--------------------------------------------------------------------------------------- ; ParseVersion ; input: ; top of stack = version string ("xx.xx.xx.xx") ; output: ; top of stack = first number in version ("xx") ; top of stack-1 = rest of the version string ("xx.xx.xx") Function ParseVersion Exch $R1 ; version Push $R2 Push $R3 StrCpy $R2 1 loop: StrCpy $R3 $R1 1 $R2 StrCmp $R3 "." loopend StrLen $R3 $R1 IntCmp $R3 $R2 loopend loopend IntOp $R2 $R2 + 1 Goto loop loopend: Push $R1 StrCpy $R1 $R1 $R2 Exch $R1 StrLen $R3 $R1 IntOp $R3 $R3 - $R2 IntOp $R2 $R2 + 1 StrCpy $R1 $R1 $R3 $R2 Push $R1 Exch 2 Pop $R3 Exch 2 Pop $R2 Exch 2 Pop $R1 FunctionEnd ;######################################################################################################################################### ;Installer Sections InstallDir "$PROGRAMFILES\EngWin" ; Section "PGA1000 EngWin Installation" PGAInstallation Section EngWin Call InstallVBDLLs SetOutPath "$(WinSysPathSysFile)" File "C:\${INSTALLFROMFOLDER}\RICHED32.DLL" SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\STOP.ICO" Push $INSTDIR/Miscellaneous\STOP.ICO Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\SPY.gif" Push $INSTDIR/Miscellaneous\SPY.gif Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\SFP.bmp" Push $INSTDIR/Miscellaneous\SFP.bmp Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\RJ45.bmp" Push $INSTDIR/Miscellaneous\RJ45.bmp Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\PerPortSys.bmp" Push $INSTDIR/Miscellaneous\PerPortSys.bmp Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\Online.ICO" Push $INSTDIR/Miscellaneous\Online.ICO Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\CaptureSize.ICO" Push $INSTDIR/Miscellaneous\CaptureSize.ICO Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\BufferSize.ICO" Push $INSTDIR/Miscellaneous\BufferSize.ICO Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\Disabled.bmp" Push $INSTDIR/Miscellaneous\Disabled.bmp Call AddSharedDLL SetOutPath "$INSTDIR" File "C:\${INSTALLFROMFOLDER}\ErrReport.dll" Push $INSTDIR\ErrReport.dll Call AddSharedDLL SetOutPath "$INSTDIR" File "C:\${INSTALLFROMFOLDER}\Aete1000API.dll" Push $INSTDIR\Aete1000API.dll Call AddSharedDLL SetOutPath "$INSTDIR" File "C:\${INSTALLFROMFOLDER}\VBTrace6.exe" Push $INSTDIR\VBTrace6.exe Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\Busy.bmp" Push $INSTDIR/Miscellaneous\Busy.bmp Call AddSharedDLL SetOutPath "$INSTDIR" !insertmacro UpgradeDLL "RICHTX32.OCX" "$INSTDIR\RICHTX32.OCX" "$SYSDIR" Push $INSTDIR\RICHTX32.OCX Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\DISK01.ICO" Push $INSTDIR/Miscellaneous\DISK01.ICO Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\Open.ICO" Push $INSTDIR/Miscellaneous\Open.ICO Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\EXIT.ICO" Push $INSTDIR/Miscellaneous\EXIT.ICO Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\Wait.ico" Push $INSTDIR/Miscellaneous\Wait.ico Call AddSharedDLL SetOutPath "$INSTDIR" File "C:\${INSTALLFROMFOLDER}\EngWinSetup.txt" Push $INSTDIR\EngWinSetup.txt Call AddSharedDLL SetOutPath "$INSTDIR" File "C:\${INSTALLFROMFOLDER}\EXCEL9.OLB" Push $INSTDIR\EXCEL9.OLB Call AddSharedDLL SetOutPath "$INSTDIR" File "C:\${INSTALLFROMFOLDER}\ComPort.txt" Push $INSTDIR\ComPort.txt Call AddSharedDLL SetOutPath "$INSTDIR/Miscellaneous" File "C:\${INSTALLFROMFOLDER}\PerPort.bmp" Push $INSTDIR/Miscellaneous\PerPort.bmp Call AddSharedDLL SetOutPath "$INSTDIR" File "C:\${INSTALLFROMFOLDER}\EngwinDefault.txt" Push $INSTDIR\EngwinDefault.txt Call AddSharedDLL SetOutPath "$INSTDIR" File "C:\${INSTALLFROMFOLDER}\ComPort.dll" Push $INSTDIR\ComPort.dll Call AddSharedDLL SetOutPath "$INSTDIR" File "C:\${INSTALLFROMFOLDER}\CommFunc.dll" Push $INSTDIR\CommFunc.dll Call AddSharedDLL SetOutPath "$INSTDIR" File "C:\${INSTALLFROMFOLDER}\DLL_Setup.txt" Push $INSTDIR\DLL_Setup.txt Call AddSharedDLL SetOutPath "$INSTDIR/ErrDef" File "C:\${INSTALLFROMFOLDER}\ErrDef.log" Push $INSTDIR/ErrDef\ErrDef.log Call AddSharedDLL SetOutPath "$SYSDIR" !insertmacro UpgradeDLL "MSWINSCK.OCX" "$SYSDIR\MSWINSCK.OCX" Push $SYSDIR\MSWINSCK.OCX Call AddSharedDLL SetOutPath "$SYSDIR" !insertmacro UpgradeDLL "COMDLG32.OCX" "$SYSDIR\COMDLG32.OCX" Push $SYSDIR\COMDLG32.OCX Call AddSharedDLL SetOutPath "$SYSDIR" !insertmacro UpgradeDLL "mscomctl.ocx" "$SYSDIR\mscomctl.ocx" Push $SYSDIR\mscomctl.ocx Call AddSharedDLL SetOutPath "$SYSDIR" !insertmacro UpgradeDLL "MSFLXGRD.OCX" "$SYSDIR\MSFLXGRD.OCX" Push $SYSDIR\MSFLXGRD.OCX Call AddSharedDLL SetOutPath "$INSTDIR" !insertmacro UpgradeDLL "API.dll" "$INSTDIR\API.dll" Push $INSTDIR\API.dll Call AddSharedDLL SetOutPath "$INSTDIR" !insertmacro UpgradeDLL "EngWinObj.dll" "$INSTDIR\EngWinObj.dll" Push $INSTDIR\EngWinObj.dll Call AddSharedDLL SetOutPath "$INSTDIR" !insertmacro UpgradeDLL "WinFunctions.dll" "$INSTDIR\WinFunctions.dll" Push $INSTDIR\WinFunctions.dll Call AddSharedDLL SetOutPath "$INSTDIR" !insertmacro UpgradeDLL "PacketEdit.dll" "$INSTDIR\PacketEdit.dll" Push $INSTDIR\PacketEdit.dll Call AddSharedDLL SetOutPath "$INSTDIR" !insertmacro UpgradeDLL "PacketCapture.dll" "$INSTDIR\PacketCapture.dll" Push $INSTDIR\PacketCapture.dll Call AddSharedDLL SetOutPath "$INSTDIR" !insertmacro UpgradeDLL "NameSpace.dll" "$INSTDIR\NameSpace.dll" Push $INSTDIR\NameSpace.dll Call AddSharedDLL SetOutPath "$INSTDIR" !insertmacro UpgradeDLL "EngWinDF.dll" "$INSTDIR\EngWinDF.dll" Push $INSTDIR\EngWinDF.dll Call AddSharedDLL SetOutPath "$SYSDIR" !insertmacro UpgradeDLL "MSSTDFMT.DLL" "$SYSDIR\MSSTDFMT.DLL" Push $SYSDIR\MSSTDFMT.DLL Call AddSharedDLL SetOutPath "$INSTDIR" File "C:\${INSTALLFROMFOLDER}\EngWin.exe" Push $INSTDIR\EngWin.exe Call AddSharedDLL SetShellVarContext current ;CreateDirectory "$SMPROGRAMS\EngWin" ;CreateShortCut "$SMPROGRAMS\EngWin\EngWin.lnk" "$INSTDIR\EngWin.exe" ;SetOutPath "$INSTDIR" ;WriteUninstaller "$INSTDIR\Uninstall.exe" SectionEnd ;######################################################################################################################################### Section -uninstEntry ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" ;Store installation folder WriteRegStr HKLM "${SoftwareHKLMLocation}\${APPNAME}" "$PROGRAMFILES\AETE\${APPNAME}" $INSTDIR WriteRegStr HKLM "${MicrosoftAddRemove}\${APPNAME}" "DisplayName" "${APPNAME}" WriteRegStr HKLM "${MicrosoftAddRemove}\${APPNAME}" "UninstallString" "$INSTDIR\uninstall.exe" WriteRegStr HKLM "${MicrosoftAddRemove}\${APPNAME}" "DisplayIcon" "$INSTDIR\icon.ico" WriteRegStr HKLM "${MicrosoftAddRemove}\${APPNAME}" "DisplayVersion" "${APPNAMEANDVERSION}" WriteRegStr HKLM "${MicrosoftAddRemove}\${APPNAME}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr HKLM "${MicrosoftAddRemove}\${APPNAME}" "Publisher" "${PRODUCT_PUBLISHER}" WriteRegStr HKLM "${MicrosoftAddRemove}\${APPNAME}" "RegCompany" "${PRODUCT_PUBLISHER}" WriteRegStr HKLM "${MicrosoftAddRemove}\${APPNAME}" "RegOwner" "${PRODUCT_PUBLISHER}" ;########################################################################################################################################## !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Create shortcuts CreateDirectory "$SMPROGRAMS\${MainATIfolder}\$STARTMENU_FOLDER" CreateShortCut "$SMPROGRAMS\${MainATIfolder}\$STARTMENU_FOLDER\${APPNAME}.lnk" "$INSTDIR\${SHORTCUTLINK}" CreateShortCut "$SMPROGRAMS\${MainATIfolder}\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" !insertmacro MUI_STARTMENU_WRITE_END SectionEnd ;################################################################################################################################################ Function un.onUninstSuccess HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." FunctionEnd Function un.onInit FunctionEnd ;################################################################################################################################################# ;Uninstaller Section Section "Uninstall" ;Deleting files from folders... Delete "$INSTDIR\*.*" ;Removing Folders Alternatively use RMDir /r "$INSTDIR" to remove all dir at one go. but not recommanded because user feel unsafe. RMDir "$INSTDIR" !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP Delete "$SMPROGRAMS\${MainATIfolder}\$MUI_TEMP\${APPNAME}.lnk" Delete "$SMPROGRAMS\${MainATIfolder}\$MUI_TEMP\Uninstall.lnk" ;Delete empty start menu parent diretories StrCpy $MUI_TEMP "$SMPROGRAMS\${MainATIfolder}\$MUI_TEMP" startMenuDeleteLoop: RMDir $MUI_TEMP GetFullPathName $MUI_TEMP "$MUI_TEMP\.." IfErrors startMenuDeleteLoopDone StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop startMenuDeleteLoopDone: ;######################################################################################################################################### ;Remove all from registry... DeleteRegKey HKLM "${MicrosoftAddRemove}\${APPNAME}" DeleteRegKey HKLM "${SoftwareHKLMLocation}\${APPNAME}" DeleteRegKey /ifempty HKLM "Software\ATI\AETE\" DeleteRegKey /ifempty HKLM "Software\ATI\" ;######################################################################################################################################### SectionEnd ;SetShellVarContext current ;CreateDirectory "$SMPROGRAMS\AeteSam" ;CreateShortCut "$SMPROGRAMS\AeteSam\AeteSam.lnk" "$INSTDIR\AeteSam.exe" ;SetOutPath "$INSTDIR" ;WriteUninstaller "$INSTDIR\Uninstall.exe" ;SectionEnd ;Section -uninstEntry ; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" "DisplayName" "AeteSam" ; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" "UninstallString" "$INSTDIR\uninstall.exe" ;SectionEnd ;Section "Uninstall" ;Delete "$INSTDIR\PerPortX.bmp" ; ;Delete "$INSTDIR\PerPort.bmp" ; ;Delete "$INSTDIR\ComPort.dll" ; ;Delete "$INSTDIR\CommFunc.dll" ; ;Push "$SYSDIR\mscomctl.ocx" ;Call un.RemoveSharedDLL ; ;Push "$SYSDIR\TABCTL32.OCX" ;Call un.RemoveSharedDLL ; ;Delete "$INSTDIR\ErrReport.dll" ; ;Delete "$INSTDIR\Aete100API.dll" ; ;Delete "$INSTDIR\Aete1000API.dll" ; ;Delete "$INSTDIR\AeteSam.exe" ; ; ;Delete "$SMPROGRAMS\AeteSam\AeteSam.lnk" ;RMDir "$SMPROGRAMS\AeteSam" ;DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" ;!insertmacro MUI_UNFINISHHEADER ;SectionEnd ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ;After you have converted the file. The VB section will be converted below. It will have something like ;Eg. ;InstallDir "$PROGRAMFILES\xxxx" ; ;Section xxxx ; ;Call InstallVBDLLs ;SetOutPath "$INSTDIR" ;File "xxxx" ;SetOutPath "$INSTDIR" ;File "xxxx" ;Push $INSTDIR\xxxx ;Call xxxxDLL ; ;SetOutPath "$SYSDIR" ;!insertmacro UpgradeDLL "xxx.ocx" "$SYSDIR\xxx.ocx" ;Push $SYSDIR\xxx.ocx ;Call AddSharedDLL ; ;...... ;........ ; ;SetShellVarContext current ;CreateDirectory "$SMPROGRAMS\xxxx" ;CreateShortCut "$SMPROGRAMS\xxxx\xxxx.lnk" "$INSTDIR\xxxx.exe" ;SetOutPath "$INSTDIR" ;WriteUninstaller "$INSTDIR\Uninstall.exe" ;SectionEnd ; ; ;Section -uninstEntry ; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" "DisplayName" "xxxx" ; WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" "UninstallString" "$INSTDIR\uninstall.exe" ;SectionEnd ; ;Section "Uninstall" ;Delete "$INSTDIR\xxxx.bmp" ; ;Delete "$INSTDIR\xxxx.bmp" ; ;...... ;...... ; ;Delete "$SMPROGRAMS\AeteSam\AeteSam.lnk" ;RMDir "$SMPROGRAMS\AeteSam" ;DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" ;!insertmacro MUI_UNFINISHHEADER ;SectionEnd ; ;Please copy ALL of commands lines under SECTION xxxx to SetShellVarContext current and DELETE the rest. ;If it happens that the copied command lines has the function !insertmacro UpgradeDLL pls add "$SYSDIR" to the end of the string ;If there is still questions. pls let me know. My email is Peter.Tham@alliedtelesyn.com ;end