RegistrySearch doesn't work

Hello all,
I am trying to do a simple registry search right before the installation is completed.
Here I have the code, in the first part I am setting the registry keys, and in the second part, I am doing the search.
But I think the search happens before the registry key is added because it cannot find it.
On the second installation, it can find it( because they are already in the registry).
Did somebody have this problem? Thank you very much for any help! :slightly_smiling_face: