Relevance optimization

(imported topic written by SystemAdmin)

We’ve got the following relevance below and are wondering if there is a more efficient way of writing said relevance? It’s looking at the current logged on user and checking to see if the BING search provider is defined and if so is it set as the default search provider. This all needs to happen in the current user context and since TEM has no way natively of doing this the we know of, we have to fake it out.

(exists key (
"HKEY_USERS\" & (string value of select (("SID from win32_useraccount where NAME=
'" & item 1 of it & "' and DOMAIN=
'" & item 0 of it & "'
") of (preceding text of first "\
" of it, following text of first "\
" of it) of (string values of selects "UserName from win32_computersystem
" of it)) of wmi) & "\Software\Microsoft\Internet Explorer\SearchScopes\
{0633EE93-D776-472f-A0FF-E1416B8B2E3A
}
") of native registry) AND ((exists value "DisplayName
" whose ("Bing
" != it) of key ("HKEY_USERS\
" & (string value of select (("SID from win32_useraccount where NAME=
'" & item 1 of it & "' and DOMAIN=
'" & item 0 of it & "'
") of (preceding text of first "\
" of it, following text of first "\
" of it) of (string values of selects "UserName from win32_computersystem
" of it)) of wmi) & "\Software\Microsoft\Internet Explorer\SearchScopes\
{0633EE93-D776-472f-A0FF-E1416B8B2E3A
}
") of native registry) AND (exists value "DefaultScope
" whose ("
{0633EE93-D776-472f-A0FF-E1416B8B2E3A
}
" != it) of key ("HKEY_USERS\
" & (string value of select (("SID from win32_useraccount where NAME=
'" & item 1 of it & "' and DOMAIN=
'" & item 0 of it & "'
") of (preceding text of first "\
" of it, following text of first "\
" of it) of (string values of selects "UserName from win32_computersystem
" of it)) of wmi) & "\Software\Microsoft\Internet Explorer\SearchScopes
") of native registry))

(imported comment written by SystemAdmin)

You definitely should avoid wmi, so you can get the key the easier way by:

"HKEY_USERS\" & component string of sid of current user

Then if you use the result of that as the key you open you will get the user’s key. There will be easier ways in the future to get this but it essentially will do the same thing.

key (
"HKEY_USERS\" & component string of sid of current user) of registry

(imported comment written by SystemAdmin)

Excellent. I just tried this and it does not seem to work in the relevance debugger though. Makes it difficult to test and compare speed or the relevance.

(imported comment written by SystemAdmin)

You can test it by putting in a ’ user “username” ’ instead of ’ current user ’ or have the client evaluate it for you.

wmi is problematic more than just for the speed. It can get messed up on some systems fairly easily.