Regarding your statements:
"In the case of backups, this allows you to specify a backup with just a file name (from T-SQL), and the backup will go to this directory." this does work.
"For data/log files, new databases will default to this location unless specified otherwise.", this does not appear to work and the database file location are the same as the master database. You can test this by setting the locations for DefaultData and DefaultLog and then run:
use master
go
select 'master' as DBName , filename from master.sys.sysfiles;
go
create database TestFileLocation
go
select 'TestFileLocation' as DBName, filename from TestFileLocation.sys.sysfiles
go
backup database TestFileLocation to disk = 'TestFileLocation.bak'
go
drop database TestFileLocation
go
Also the registry read statements returns nulls because the statment:
set @ServerName = SUBSTRING(@ServerName,CharIndex('\', @Servername) , 250)
causes the "\" to be included as part of the @servername and needs to change to:
set @ServerName = SUBSTRING(@ServerName,CharIndex('\', @Servername) + 1 , 250)
SQL = Scarcely Qualifies as a Language