如何解决类型不匹配的VBScript运行时错误;代码:800a000D


0

我可能没有这样做,但我正在尝试修改VBScript以查找Windows产品密钥以支持查找Microsoft Office Pro的产品密钥。这是代码,但我希望“unknown”文件夹名称与通配符具有相同的效果。我知道在VBScript中无法使用实际的通配符,但是如何在脚本中返回“DigitalProductID”的注册表值而不指定“unknown”文件夹?或者我在其他地方更改代码?

Set WshShell = CreateObject("WScript.Shell")
MsgBox ConvertToKey(WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Registration\unknown\DigitalProductId"))

Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
x = 14
Do
Cur = Cur * 256
Cur = Key(x + KeyOffset) + Cur
Key(x + KeyOffset) = (Cur \ 24) And 255
Cur = Cur Mod 24
x = x -1
Loop While x >= 0
i = i -1
KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
If (((29 - i) Mod 6) = 0) And (i <> -1) Then
i = i -1
KeyOutput = "-" & KeyOutput
End If
Loop While i >= 0
ConvertToKey = KeyOutput
End Function

你打开了 regedit 并手动查找“未知”部分,替换命中并运行脚本?
Seth

Answers:


0

下一个简单脚本枚举给定注册表项的子键:

Option Explicit
On Error Goto 0

Dim strLog, strComputer, objRegistry, strKeyPath, key, arrsubKeys

strLog = ""
strComputer = "."

Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
      & strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Registration\"
strKeyPath = "SOFTWARE\Wow6432Node\Adobe\"    '''' key path for demonstration 

strLog = strLog & vbNewLine & "subkeys of HKLM\" & strKeyPath

objRegistry.EnumKey HKLM, strKeyPath, arrsubKeys

If VarType( arrsubKeys) = 8204 Then
    For Each key In arrsubKeys
        strLog = strLog & vbNewLine & key
    Next
End If

Wscript.Echo strLog
Wscript.Quit

' useful constants '
' Registry: Braches and Corresponding Hexadecimal Values '
Const HKCR = &H80000000 'HKEY_CLASSES_ROOT
Const HKCU = &H80000001 'HKEY_CURRENT_USER
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Const HKU  = &H80000003 'HKEY_USERS
Const HKCC = &H80000005 'HKEY_CURRENT_CONFIG
Const HKDD = &H80000006 'HKEY_DYN_DATA
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.