• This is basically the command that is issued when you get the property via SSMS:

    DECLARE @smoBackupDirectory varchar(250)

    EXEC master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'BackupDirectory', @smoBackupDirectory OUTPUT

    PRINT @smoBackupDirectory

    GO

    This should return the BackupDirectory key for the instance you run it on without doing a bunch of conditional logic based on the DB engine version. This should work in 2000 on up. I think it returns an error if the key does not exist, so watch out for that.

    I know there are tools that report this information for multiple instances, but I figured I could learn SSIS and collect a bunch of useful data (database file size trending and free space monitoring) if I did it myself. The SSIS package collects Server, Instance, Database, Database File, and Backup Set data into a repository similar to the one featured here:

    http://www.windowsitpro.com/article/sql-server/DBA-Repository-2010.aspx

    Hope this helps.

    Caine