Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in windows 10 if users left in ProfileList #136

Open
chirrindul opened this issue Sep 19, 2023 · 0 comments
Open

Exception in windows 10 if users left in ProfileList #136

chirrindul opened this issue Sep 19, 2023 · 0 comments

Comments

@chirrindul
Copy link

In our systems, for some reason, there are enties under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList that has only one "(Default)" value.

This is the reason to see the following exception in CyLR version 3.0.0:
2023-09-19T09:11:43 [error] Error occurred while collecting files:
System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.
at CyLR.CollectionPaths.FindUsers()+MoveNext()
at CyLR.CollectionPaths.GetPaths(Arguments arguments, List 1 additionalPaths, Boolean Usnjrnl, Logger logger)
at CyLR.Program.Main(String[] args)

You can simulate our environment creating a new Key under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList with a name similar to S-1-5-21-1831369195-1341884237-3597795279-1000 and executing CyLR.

To solve the issue we have changed the FindUsers function in this way (changed from (void) to (Logger logger) in order to debug):

public static IEnumerable<UserProfile> FindUsers(Logger logger)
{
var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList");
foreach (string name in key.GetSubKeyNames())
{
var path = $@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\{name}";
var profile = Registry.GetValue(path, "ProfileImagePath", null);
if (profile != null)
{
logger.info("Found User with ProfilePath: " + (string)Registry.GetValue(path, "ProfileImagePath", string.Empty));
var result = new UserProfile
{
UserKey = name,
Path = $@"{path}\ProfileImagePath",
ProfilePath = (string)Registry.GetValue(path, "ProfileImagePath", string.Empty),
FullProfile = (int)Registry.GetValue(path, "FullProfile", 0)
};
if (result.FullProfile != -1) yield return result;
}
}
}

If you think this is a good change, include it in your next release.

Thanks for your project.

CollectionPaths.cs.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant