I have a C# application that needs to get values which they are stored in user profile in registry installing it in Windows Server 2012. I execute my application with Task Scheduler setting it 'run whether user is logged on or not' . To get registry values from user profiles I access through HKU with SID of user profile (like the code below).
using (RegistryKey rk = RegistryKey.OpenBaseKey(RegistryHive.Users, RegistryView.Default))
{
using (RegistryKey key = rk.OpenSubKey(WindowsIdentity.GetCurrent().User + "\\SOFTWARE", RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.FullControl))
{
foreach (var item in key.GetSubKeyNames())
{
file2.WriteLine(DateTime.Now + ": Getsubkeynames 2 :" + item);
}
}
}
So my problem is I cannot access registry values of user profile after logging off. I'm curious if it's able to do that or not.