You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 toS-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
The text was updated successfully, but these errors were encountered: