Registry read permissions (scripting) on Windows Server 2003

vbscriptwindows-registrywindows-server-2003

Executing the following VBScript on our Windows Server 2003

Set p_shell = CreateObject("WScript.Shell")
p_shell.RegRead("HKEY_USERS\S-1-5-19\")

yields the following error

C:\Documents and Settings\Administrator\Desktop>cscript test.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\Documents and Settings\Administrator\Desktop\test.vbs(2, 1) WshShell.RegRead:
 Unable to open registry key "HKEY_USERS\S-1-5-19\" for reading.

although the user (Administrator) definitely has the necessary permissions. Reading the key directly from the command line works:

C:\Documents and Settings\Administrator\Desktop>reg query HKEY_USERS\S-1-5-19\ /ve

HKEY_USERS\S-1-5-19
    (Default)    REG_SZ    (value not set)

and the permissions (as shown by regedit) are default: Full Control (LOCAL SERVICE, SYSTEM, Administrators), Read (RESTRICTED).

Why does the VBScript fail to read the default value of the key? Executing the same script (elevated) on a Vista machine works fine.

(I know that this script serves no useful purpose — it's a minimal example to demonstrate the problem.)

Best Answer

I get that error unless I put a specific registry key in the read command

Set p_shell = CreateObject("WScript.Shell")
p_shell.RegRead("HKEY_USERS\S-1-5-19\Console\HistoryBufferSize")
Related Topic