On some Windows systems the SOFTWARE\Microsoft\OneDrive registry key is REG_SZ rather than REG_EXPAND_SZ.
Change-Id: I3ccb8771377a73456f48da1b5cfae668130b3f7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/623515
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
return "", fmt.Errorf("reading UserFolder failed: %v", err)
}
- if valtype == registry.EXPAND_SZ {
+ // REG_SZ values may also contain environment variables that need to be expanded.
+ // It's recommended but not required to use REG_EXPAND_SZ for paths that contain environment variables.
+ if valtype == registry.EXPAND_SZ || valtype == registry.SZ {
expanded, err := registry.ExpandString(path)
if err != nil {
return "", fmt.Errorf("expanding UserFolder failed: %v", err)