Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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


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.