Check for MS SQL and Install

Got a problem you cannot solve? Try here.
MaudDib
Posts: 16
Joined: Wed Jun 10, 2015 2:50 am

Check for MS SQL and Install

Postby MaudDib » Fri Jun 12, 2015 8:12 am

Dear Support

I'm new to using IA to make my installer. Let me first describe my circumstances before I ask my question.

Basically, I'm trying to build an installer where the user has different options as to what version of our application they want to install. After that choice they have a choice of where their database is hosted (Server or locally). After this option there are some pre-requisites that need to be checked and installed. Depending on if the user chooses that the database is hosted locally, then the install must check if the latest Microsoft SQL is install and if so, then show it and give option to install newer version or just install the newest version.

Now, my problem is that I don't seem to find any information about how to do this SQL check. I'm sure that it is easy but i'm really struggling to figure this out. I'd really appreciate any help and or a push in the right direction.

Thanks.

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Check for MS SQL and Install

Postby FrancescoT » Fri Jun 12, 2015 1:19 pm

Dear MaudDib,

I suppose you can query the installed SQL version(s) from the target system registry.

Under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names", you should find the defined Instances.
Once you have the Instance name, you should be able to query the following key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\<INSTANCE_NAME>\Setup
Here there are 2 values that describe the version installed:
•Edition: Contains the name of the edition installed
•PatchLevel: Contains the complete version number

You can use the "Read Registry" command via MSICode to query the above Keys, then use the results to conditionally run a MS SQL Installer or update any MS SQL version.

Hope this helps you.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

MaudDib
Posts: 16
Joined: Wed Jun 10, 2015 2:50 am

Re: Check for MS SQL and Install

Postby MaudDib » Mon Jun 15, 2015 2:00 am

Hi Francesco

Thank you for your quick response but sadly i'm still stuck... bleak!

Firstly, I was not able to find the exact registry key but I did note two different location, very close to the key you mentioned, for the information regarding the SQL Instances in my register (see the images).

Registary 01.JPG
Registary 01.JPG (38.17 KiB) Viewed 10349 times


Registary 02.JPG
Registary 02.JPG (39.56 KiB) Viewed 10349 times


I tried the following code to read the registry, which is not retrieving any information for me and i'm not sure why.

Code: Select all

~Read Registry~
~{41A04EE9-C525-4DEA-BF2D-9E212BB13CAB}~
~MSSQL_INSTANCES|~
~2~
~HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server~
~InstalledInstances~
~Set Variable~
~{9F61083F-5A00-4B74-B6B3-FD6983FBCF4E}~
~MSSQL_INSTANCES$MYAH$MYAH$FALSE~
~~
~MessageBox~
~{F6DFF1BA-A36A-451C-8767-E21808C26D25}~
~Info~
~SQL: $MSSQL_INSTANCES$~
~0~
~1~
~~


I've tried different variations of the following strings in the read:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\InstalledInstances

Well, i'm not sure what i'm doing incorrectly in the above code but I was hoping to get a string variable, then split it up and then to loop through it to check against the second registry key (that you mentioned) to get the version of the SQL instance.

At this point, I'd simply appreciate any ideas as to why i'm not able to read the registry?

Thanks

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Check for MS SQL and Install

Postby FrancescoT » Mon Jun 15, 2015 1:10 pm

Dear MaudDib,

because this could be useful for other users as well, I have realized a sample at such purpose.
You can download the "Enumerate MS SQL Instances sample" from the following link.
http://www.installaware.com/forum/viewtopic.php?f=2&t=6772&p=25655#p25655

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

MaudDib
Posts: 16
Joined: Wed Jun 10, 2015 2:50 am

Re: Check for MS SQL and Install

Postby MaudDib » Wed Jun 17, 2015 3:46 am

Hi FrancescoT

Thanks Francesco. Your sample worked for me.

Just a note: I performed a test on the example code and it seams that if the checks for Windows Version (x86) is removed (see images), then the registry check fails. It would be interesting to know why this is as I would have thought that such a check would have been setup within the MISCode, "Read Registry" and "Find All Registry Values". - just a thought...

Thanks again for the help

(code set before reading the registry)
Windows Version Check and Set - 01.JPG
Windows Version Check and Set - 01.JPG (27.05 KiB) Viewed 10323 times


(code set after reading the registry)
Windows Version Check and Set - 02.JPG
Windows Version Check and Set - 02.JPG (16.36 KiB) Viewed 10323 times

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Check for MS SQL and Install

Postby FrancescoT » Wed Jun 17, 2015 1:18 pm

Dear MaudDib,

by default the install process runs as 32 bit mode and the " Set x64 - Native 64 bit Windows ..." statement switches to native 64 bit mode.
This is required to avoid the OS re-direction of the key-root "HKEY_LOCAL_MACHINE\SOFTWARE" to "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node" with x64 target OSes. Otherwise in this case, the "Read Registry" command will fail to query the correct key path when the target OS is a x64 platform.

Hope this helps you.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

MaudDib
Posts: 16
Joined: Wed Jun 10, 2015 2:50 am

Re: Check for MS SQL and Install

Postby MaudDib » Fri Jun 19, 2015 3:00 am

Hi Francesco

Thanks, that makes sense to me.

Best regards

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Check for MS SQL and Install

Postby FrancescoT » Fri Jun 19, 2015 1:12 pm

:D
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 195 guests