Shima.Y
Shima.Y

Reputation: 383

How to check if SQL Server Management Studio is installed on a system programmatically?

I need to find whether SQL Server Management Studio is installed on a system or not. I need this specially when an instance of SQL Server Express is installed on a system by installing Visual Studio but with no Management Studio installed on the system.

For more information, I can find all instances of SQL Server installed on a system but I need to understand that is Management Studio also installed on system or not.

Upvotes: 4

Views: 9535

Answers (2)

Ghasem
Ghasem

Reputation: 15573

You can check its registry key and see if it returns null:

private RegistryKey _regSql = Registry.LocalMachine.OpenSubKey
            (@"HKLM\Software\Classes\Applications\sqlwb.exe", false);

if (_regSql == null) //If it's null then  SQL Server management is not installed
{
   //Do something
}

Also the are two more registry locations you can check:

HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\SSMSEE
SOFTWARE\Microsoft\Microsoft SQL Server\90\Tools\ClientSetup

Edit

According to this documents, while using the address SOFTWARE\Microsoft\Microsoft SQL Server\90\Tools\ClientSetup change the the number part (90) based on the versions you want to check:

90   | SQL Server 2008
100  | SQL Server 2008 R2
110  | SQL Server 2012
120  | SQL Server 2014 
130  | SQL Server 2016
140  | SQL Server 2017

Upvotes: 3

Tanmay Nehete
Tanmay Nehete

Reputation: 2198

you can use WMI as has been mentioned:

ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
foreach(ManagementObject mo in mos.Get())
{
       if(mo["Name"].ToString().Equals("Application Name")) //
       {
         return true;
       }
}

Upvotes: 1

Related Questions