I want to read a REG_DWORD to put the information in BGinfo with a VBS file
I do this script but not works
Const HKEY_USERS=&H80000003
strComputer = "."
DW="tct"
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "HKEY_USERS\S-1-5 20\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings"
strValueName = "DownloadMode"
oReg.GetDWORDValue HKEY_USERS,strKeyPath,strValueName,dwValue
dw="t "& swValue
msgbox DW
In message box show t but not swValue
I'm interested to show the values into DownloadMode if it 0 or 1, to registry automatically in the field of Bginfo data access
what am I doing wrong?
User S-1-5-20 is the Network Service account. Your script has to be running with elevated privileges to read the values there. To see this for yourself, open a regular Cmd prompt and also open another Cmd prompt as Administrator. Run either one of the following scripts. They will error out under the regular Cmd prompt, but will return the value for DownloadMode (if it exists) under the Administrator Cmd prompt.
Read dword value using RegRead:
Read dword value using WMI:
Note: I could not find a reference for a "DownloadMode" dword value under this key. I created the value for the purposes of testing this script. I did find a reference to this key under HKLM with a DownloadMode STRING value and DODownloadMode dword value under a "Config" key. So, be sure that you have the key, valuename, and data type correct.