Listing 5. Code That Detects a Server Running Under the LocalSystem Account DECLARE @LocalSystem nvarchar(200) EXEC master.dbo.xp_regread 'HKEY_LOCAL_MACHINE' , 'SYSTEM\CurrentControlSet\ Services\MSSQLSERVER', 'ObjectName', @LocalSystem OUTPUT IF @LocalSystem = 'LocalSystem' PRINT 'FAIL'