Seite 1 von 1

Registry keys with spaces - still an issue

Verfasst: 14 Jun 2017, 03:04
von SisterOfMercy
A registry key with spaces cannot be opened when run in a 64-bit process.

Code: Alles auswählen

DefVar $Administrator_SID$
DefVar $escUserProfile$
Set $Administrator_SID$ = GetUserSID("Administrator")
Set $escUserProfile$ = "%" + "USERPROFILE" + "%"
Registry_local_admin_folders /SysNative

[Registry_local_admin_folders]
openkey [HKEY_USERS\$Administrator_SID$\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]
set "Desktop" = REG_EXPAND_SZ:"$escUserProfile$\Desktop"
set "Personal" = REG_EXPAND_SZ:"$escUserProfile$\My Documents"
Running the Registry_local_admin_folders with the /64Bit parameter the results are the same.

Code: Alles auswählen

[5] [Jun 10 00:13:10:516] [gce-settings]     Execution of Registry_local_admin_folders
[5] [Jun 10 00:13:10:516] [gce-settings]       Error: Registry key [HKEY_USERS\S-1-5-21-538005352-711716544-1927554804-500\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]   could not be opened by RegCreateKeyEx,  Errorno: 87 "The parameter is incorrect.<"
[5] [Jun 10 00:13:10:516] [gce-settings]                   Error: Variable "Desktop"  could not be set  
[5] [Jun 10 00:13:10:516] [gce-settings]                   Error: Variable "Personal"  could not be set  
I've once opened a topic, but I didn't explain it very well back then: viewtopic.php?f=8&t=4951

Re: Registry keys with spaces - still an issue

Verfasst: 03 Jul 2017, 17:10
von n.wenselowski
Hi SisterOfMercy,

thank you for bringing this to our attention - again!
SisterOfMercy hat geschrieben:I've once opened a topic, but I didn't explain it very well back then: viewtopic.php?f=8&t=4951
I did open an internal ticket referencing to this with your proposed fix attached.
I assume that there probably will be more lines that need a fix like the one in the old topic applied.


With kind regards

Niko

Re: Registry keys with spaces - still an issue

Verfasst: 22 Apr 2022, 12:21
von schmitz
Hello SisterOfMercy,

there was a problem with spaces in registry keys which was fixed some time ago but I think your error is of a different kind. I could reproduce it and it seems to depend on paths and permissions:
[HKEY_USERS\.Default\User Shell Folders] and [HKEY_USERS\.Default\UserShellFolders] work fine for me since HKEY_USERS\.Default already exists, whereas
[HKEY_USERS\User Shell Folders] and [HKEY_USERS\UserShellFolders] produce your error.
Maybe your HKEY_USERS\$Administrator_SID$ does not exist and you do not have the permission to create it; that might be the reason why

Code: Alles auswählen

openkey [HKEY_USERS\$Administrator_SID$\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]
fails.
Please check this if you are still on the case ;)

Kind regards
Anja