wie Sie den VBScript-Laufzeitfehler für Typkonflikte umgehen können; Code: 800a000D

840
kdave001

Ich mache dies möglicherweise nicht richtig, aber ich versuche, ein VBScript zu ändern, um den Windows-Produktschlüssel zu finden, um das Finden eines Produktschlüssels für Microsoft Office Pro zu unterstützen. Hier ist der Code, aber ich möchte, dass der "unbekannte" Ordnername den gleichen Effekt wie ein Platzhalter hat. Ich weiß, dass ein tatsächlicher Platzhalter in VBScript nicht möglich ist. Was kann ich jedoch tun, um den Registrierungswert für "DigitalProductID" im Skript zurückzugeben, ohne den Ordner "unknown" anzugeben? Oder ändere ich den Code woanders?

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 
0
Sie öffnen `regedit 'und suchen diesen" unbekannten "Teil manuell, ersetzen ihn und führen das Skript aus? Seth vor 7 Jahren 0

1 Antwort auf die Frage

0
JosefZ

Das nächste einfache Skript listet Unterschlüssel eines bestimmten Registrierungsschlüssels auf:

Option Explicit On Error Goto 0  Dim strLog, strComputer, objRegistry, strKeyPath, key, arrsubKeys  strLog = "" strComputer = "."  Set objRegistry = GetObject("winmgmts:!\\" _ & 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