You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

RegRead函数返回错误值问题求助

Troubleshooting Your Registry Read Script

Let’s break down why your VBScript is suddenly returning incorrect results when reading that ShellFolder Attributes value—here are the most likely issues and fixes:

1. Fix the Typo in Your Registry Path

First off, your registry path has an extra space after 88B0-:

FileExt = "HKEY_CLASSES_ROOT\CLSID\{F02C1A0D-BE21-4350-88B0- 7367FC96EF3C}\ShellFolder\Attributes"

That stray space makes the path invalid—Windows won’t recognize the CLSID with that extra character. Correct it to:

FileExt = "HKEY_CLASSES_ROOT\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder\Attributes"

This is the most common reason a previously working script breaks out of nowhere.

2. Handle the Binary Data Type Properly

The Attributes value under ShellFolder is a REG_BINARY type. When WScript.Shell.RegRead reads binary data, it returns a string of hexadecimal characters (like f0400000) instead of a human-readable integer. If you’re expecting a numeric value, you’ll need to convert that hex string to decimal—plus, note that this value uses little-endian byte ordering, so we have to reverse the byte order during conversion.

Here’s an adjusted script to handle this:

FileExt = "HKEY_CLASSES_ROOT\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder\Attributes"
Set Shell = WScript.CreateObject("WScript.Shell")
' Read the raw hex string from the registry
hexAttr = Shell.RegRead(FileExt)
' Convert hex to decimal (account for little-endian byte order)
decAttr = CLng("&H" & Right(hexAttr, 2) & Mid(hexAttr, 5, 2) & Mid(hexAttr, 3, 2) & Left(hexAttr, 2))
WScript.Echo "Decimal Attributes Value: " & decAttr
WScript.Echo "Raw Hex Attributes Value: " & hexAttr

3. Check for 32-bit/64-bit Registry Redirection

If you’re running a 32-bit script on a 64-bit Windows system, WScript.Shell.RegRead will automatically redirect to the HKEY_CLASSES_ROOT\Wow6432Node branch, which might not hold the value you’re targeting.

To force reading the 64-bit registry, use WMI instead of WScript.Shell:

strPath = "SOFTWARE\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder"
strValue = "Attributes"
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
' Use &H80000000 for 64-bit registry; swap to &H80000002 for 32-bit
objReg.GetBinaryValue &H80000000, strPath, strValue, arrBytes
' Convert the byte array to a readable hex string
hexAttr = ""
For Each byte In arrBytes
    hexAttr = hexAttr & Right("0" & Hex(byte), 2)
Next
WScript.Echo "Hex Attributes Value: " & hexAttr

4. Verify Permissions

UAC restrictions can sometimes block access to system-level registry keys even if the script worked before. Try running your script as an administrator—right-click the script file and select Run as administrator to see if that resolves the incorrect result.

内容的提问来源于stack exchange,提问作者Melis Dost

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:53:59