0

我正在使用 technet 中的示例尝试从 HKLM\Microsoft\Windows\CurrentVersion\Run 读取一个名为 MyStartupExe 的 dword / 字符串。它返回空。这个常规示例有效:

Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set oReg=GetObject( _
   "winmgmts:{impersonationLevel=impersonate}!\\" &_
    strComputer & "\root\default:StdRegProv")
strKeyPath = "Console"
strValueName = "HistoryBufferSize"
oReg.GetDWORDValue _
   HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
WScript.Echo "Current History Buffer Size: " & dwValue

我对它的改编不起作用。字符串和 dword 值存在于注册表中我要查找的键路径中。

const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject( _
   "winmgmts:{impersonationLevel=impersonate}!\\" &_
    strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
strValueName = "MyStartUpExe"
oReg.GetDWORDValue _
   HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
WScript.Echo "MyStartupExe" & dwValue
4

2 回答 2

1

"MyStartUpExe" 很可能是一个REG_SZ值,而不是一个REG_DWORD值,因此您必须使用GetStringValue()而不是GetDWORDValue().

oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, value
WScript.Echo "MyStartUpExe" & value
于 2012-09-14T21:21:45.787 回答
0

请参阅WMI StdRegProv 类

或者,您可以只使用Shell.RegRead读取不知道值数据类型的注册表值。如果返回码RegRead为 0(成功),则存在一个 reg 值,否则如果返回码是一些一般错误代码,例如&h800xxxxx等,则不存在 reg 值。要检查您的操作系统架构类型,请查询Win32_Processor.Architecture值(其中 '0' = 'x86' 或 '9' = 'x64')。

于 2012-09-16T02:48:31.173 回答