• Hi,

    I actually worked on this issue for almost half a day and I couldn't resolve a snack with John's code a few days ago, and I just gave up. 🙁

    He uses the following

    DECLARE @KEY_VALUE varchar(100)

    DECLARE @ServiceAccountName varchar(100)

    EXECUTE master..xp_regread 'HKEY_LOCAL_MACHINE', @KEY_VALUE, 'ObjectName', @ServiceAccountName OUTPUT

    SELECT @ServiceAccountName as 'SQLAgent Account'

    however, I've run that code on several servers and in some of them the result is 'NULL'.

    (it doesn't matter the service, it happens with several services).

    The only thing I could figure out is that when I run the following code:

    declare @regkey varchar (100)

    SET @REGKEY = 'System\CurrentControlSet\Services\SQLAgent$instance_name'

    EXEC master..xp_regenumvalues @rootkey='HKEY_LOCAL_MACHINE',@key=@regkey

    for the Object value I get the following:

    Value data value data

    ObjectName.\sqlserviceNULLNULL

    It seems that for some cases the registry key has two sets of values, weird.

    Anyone has ideas of why this might be?

    Thank you

    Miguel