Improve userprofile check robustness

This commit is contained in:
crschnick
2025-05-21 06:01:42 +00:00
parent 61c6c0d78b
commit bcf58bc8e4
@@ -62,8 +62,19 @@ public interface OsType {
@Override
public String getUserHomeDirectory(ShellControl pc) throws Exception {
return pc.executeSimpleStringCommand(
var profile = pc.executeSimpleStringCommand(
pc.getShellDialect().getPrintEnvironmentVariableCommand("USERPROFILE"));
if (!profile.isEmpty()) {
return profile;
}
var name = pc.executeSimpleStringCommand(
pc.getShellDialect().getPrintEnvironmentVariableCommand("USERNAME"));
if (!name.isEmpty()) {
return "C:\\Users\\" + name;
}
return "C:\\Users\\User";
}
@Override