2 Replies - 1511 Views - Last Post: 12 December 2011 - 10:10 PM Rate Topic: -----

#1 jrautza  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-December 11

Find SQL Server instance install path using VB.NET in Windows 7

Posted 12 December 2011 - 05:08 PM

I have an application that allows the user to conduct database backups and restores. The users had been using Windows XP, with network security that allowed users to read the registry. For restores, the installation path to the SQL Server named instance was easily found by looking up the instance name in the registry using

restoreDir = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\" & m_DatabaseInstanceName & "\Setup", "SQLPath", Nothing).ToString


They have recently upgraded to Windows 7, and locked down the registry so that users can not read values from it. Is there a way (via code) to find the path to a named instance of SQL Server, so that the app can automatically place the database files (mdb & ldb) in the correct folder?

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Find SQL Server instance install path using VB.NET in Windows 7

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Find SQL Server instance install path using VB.NET in Windows 7

Posted 12 December 2011 - 05:26 PM

Well the instance name is usually in C:\Program Files\Microsoft SQL Server\*versionofsql*.*nameofinstance*. Could be wrong though, at least that's where I always find it.
Was This Post Helpful? 0
  • +
  • -

#3 jrautza  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-December 11

Re: Find SQL Server instance install path using VB.NET in Windows 7

Posted 12 December 2011 - 10:10 PM

In our case, each instance of SQL Server is installed in C:\Program Files\Microsoft SQL Server\MSSQL.#. Where the # value is an integer automatically incremented with each installation/instance. So on a machine with two named instances and Reporting Services installed, you would see three folders named MSSQL.1, MSSQL.2 and MSSQL.3, without knowing exactly which one is which. So we programatically look-up the install folder of the named instance from within the application via the registry. But since switching to Windows 7, the network security does not allow the registry to be read.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1