Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I find the folder path where my MSSQL server 2008 R2 is installed, inside my C# code?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The installer WMI classes (Win32_Product, Win32_SoftwareFeature and Win32_SoftwareElement) don't provide this information: there is no requirement that there is a single location at any of those levels. Therefore something application specific is needed.

Looks like

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\100

contains VerSpecificRootDir with the base folder. And it looks like replacing the 100 with the correct number (ie. SQL Server version times ten) will work across versions.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.