Detection of MSDE / SQL Server in user's Computer
Hi Everyone!
Recently I've made an installer in NSIS to install MSDE.
There I was facing one issue as how to detect MSDE/SQL Server in user's computer before installing MSDE. After lot of trial and help from the members of this beautiful community I came up with an simple solution.
Please note the following coding is just to check whether there is any SQL Server / MSDE exists or not in user's computer. There is no specific version checking or instance name's checking. The simple & tested code is:
ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\MSSQLServer\Setup" SQLPath ;ProductCode
${If} $R0 == ""
;MessageBox MB_ICONEXCLAMATION|MB_OK "SQL Server not detected, press any key to install"
${Else}
MessageBox MB_ICONEXCLAMATION|MB_OK "SQL Server/MSDE already installed!$\nSQL Path:$R0$\nSetup is terminating the installation process."
Quit
${EndIf}
That's it! But if you are interested into version info of SQL then you may try something like this:
ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion" CurrentVersion
MessageBox MB_ICONEXCLAMATION|MB_OK "MSDE/SQL Server version: $R0"
With regards,