Created
June 1, 2009 08:56
-
-
Save hm2k/121314 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'keyfinder.vbs v0.1 by HM2K (01/06/09) | |
Const HKEY_CLASSES_ROOT = &H80000000 | |
Const HKEY_CURRENT_USER = &H80000001 | |
Const HKEY_LOCAL_MACHINE = &H80000002 | |
Const HKEY_USERS = &H80000003 | |
Function ReadFile(sFile) | |
Dim oFSO, oFile, sText | |
Set oFSO = CreateObject("Scripting.FileSystemObject") | |
If oFSO.FileExists(sFile) Then | |
Set oFile = oFSO.OpenTextFile(sFile, 1) | |
Do While Not oFile.AtEndOfStream | |
sText = oFile.ReadLine | |
If Trim(sText) <> "" Then | |
LineHandler sText | |
End If | |
Loop | |
oFile.Close | |
Else | |
WScript.Echo "The file was not there." | |
End If | |
End Function | |
Function LineHandler(txt) | |
result=LineParser(txt) | |
If Not IsEmpty(result) Then | |
WScript.Echo result | |
End If | |
End Function | |
Function LineParser(txt) | |
a = Split(txt, "|", -1, 1) | |
name = a(0) | |
For Each y in a | |
If (Instr(y, "=") And Not name = y) Then | |
aa=Split(y, "=", -1, 1) | |
If (aa(0) <> "") Then | |
prefix = aa(0) & ": " | |
End If | |
k=aa(1) | |
ab=Split(k, "\", 2, 1) | |
root=ab(0) | |
path=ab(1) | |
key=aa(2) | |
val=GetRegKeyValue(root, path, key) | |
If Not IsNull(val) Then | |
If Not IsNull(prefix) Then | |
val=prefix & val | |
End If | |
o = o & val & vbcrlf | |
End If | |
End If | |
Next | |
'Return output | |
If Not IsEmpty(o) Then | |
LineParser=name & vbcrlf & o | |
End If | |
End Function | |
Function GetRegKeyValue(root, path, key) | |
If (root = "HKEY_LOCAL_MACHINE") Then | |
root=HKEY_LOCAL_MACHINE | |
Else | |
root=HKEY_CURRENT_USER | |
End If | |
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") | |
oReg.GetStringValue root, path, key, val | |
'Return value | |
GetRegKeyValue = val | |
End Function | |
ReadFile("keyfinder.cfg") | |
WScript.Echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment