SQLDMO Installer
From NSIS Wiki
Jump to navigationJump to search
Author: jilchev (talk, contrib) |
Description
I was looking for a standalone solution to deploy SQLDMO and after I couldn't find such in the NSIS Wiki or elsewhere on the web I decided to do it! Based on info available on the web: http://support.microsoft.com/Default.aspx?kbid=326613 and similar merge module by Anthony Glenwright.
Note that msvcr71.dll is now required, if the DMO files have been taken from MSDE SP4 or SQLServer SP4.
The Script
Here is what came at the end (comments are welcome): Note: There was an uninstall issue in version 1.0 of this script! Thanks Zdravko!
; SQLDMO Installer ; English Language version ; by Jordan Ilchev (Tangra Inc.) ; based on Microsoft KB#326613 & similar Anthony Glenwright's Merge Module (MSI/MSM) ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "SQLDMO Installer" !define PRODUCT_VERSION "1.1" !define PRODUCT_WEB_SITE "http://support.microsoft.com/Default.aspx?kbid=326613" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" SetCompressor lzma ; MUI 1.67 compatible ------ !include "MUI.nsh" ; MUI Settings !define MUI_ABORTWARNING !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" ; Welcome page !insertmacro MUI_PAGE_WELCOME ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page !insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "English" ; Reserve files !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "SQLDMO-Setup.exe" InstallDir "$PROGRAMFILES\Microsoft SQL Server\80\Tools\Binn" ShowInstDetails show ShowUnInstDetails show Section "MainSection" SEC01 ; Check if SQL DM is registered on target system ReadRegStr $0 HKCR CLSID\{10020100-E260-11CF-AE68-00AA004A34D5}\VersionIndependentProgID "" StrCmp $0 "" install_go 0 DetailPrint "Key Value: $0" DetailPrint "SQLDMO already installed!" DetailPrint "Setup is terminating the installation process." MessageBox MB_OK "SQLDMO already installed!$\nSetup is terminating the installation process." Quit install_go: ClearErrors SetOutPath "$INSTDIR" SetOverwrite ifnewer File "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlsvc.DLL" File "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlresld.DLL" File "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQLDMO.dll" File "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\w95scm.DLL" SetOutPath "$INSTDIR\Resources\1033" File "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\Resources\1033\sqlsvc.rll" File "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\Resources\1033\SQLDMO.RLL" SetOutPath "$SYSDIR" File "C:\WINDOWS\system32\sqlwid.dll" File "C:\WINDOWS\system32\sqlwoa.dll" ;Register SQLDMO.DLL ExecWait 'regsvr32.exe /s "$INSTDIR\SQLDMO.dll"' SectionEnd Section -Post WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \ "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \ "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \ "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \ "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \ "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" SectionEnd Function un.onUninstSuccess HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." FunctionEnd Function un.onInit MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \ "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 Abort FunctionEnd Section Uninstall ;UnRegister SQLDMO.DLL ExecWait 'regsvr32.exe /s /u "$INSTDIR\SQLDMO.dll"' Delete "$INSTDIR\uninst.exe" Delete "$SYSDIR\sqlwoa.dll" Delete "$SYSDIR\sqlwid.dll" Delete "$INSTDIR\Resources\1033\SQLDMO.RLL" Delete "$INSTDIR\Resources\1033\sqlsvc.rll" Delete "$INSTDIR\w95scm.DLL" Delete "$INSTDIR\SQLDMO.dll" Delete "$INSTDIR\sqlresld.DLL" Delete "$INSTDIR\sqlsvc.DLL" RMDir "$INSTDIR\Resources\1033" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" SetAutoClose true SectionEnd
Enjoy! J.