LuckyDuck528
Programmer
Below I have included sample input and my full code to help solve this issue. If you run the program it shoul be self explanitory where the problem is. For each line in the code, the script:
1. Makes a copy of the registry
2. Opens the copy and pull out everything has to do w. the
input string
3. Goes through the filtered info and searches for key
items that are always present in the strings I am
looking at
4. Filter those key items into array values that are pulled
out and used to find the location of the .dll
corresponding to the string name.
It works perfectly the first time through. After that, I can't seem to get the array values to reset, they keep adding on to the original, therefore, I never get the location of the next string. The script will tell me the name of the next string and give me the .dll location of the first string.
I had alot of echo statements in there showing me what the values of variables and arrays were at different palces but I took most of them out and just left the ReDim's at the bottom of the code b/c they seemed to be working when I checked them w/ echo's. Maybe my problem is somewhere else? I am not very advanced in vbs so could easily be missing something.
Please help, I think I just need another pair of eyes to see what I am missing.
Thank you sincerely for your time. It's very appreciated.
Find_Input.txt
Scripting.FileSystemObject
Microsoft.XMLDOM
MSXML2.DOMDocument
ConnectionInfo.clsConnectionInfo
ADODB.Recordset
ADODB.Command
ADODB.Connection
Scripting.Dictionary
MSWC.BrowserType
SMTPsvg.Mailer
CDONTS.NewMail
DERuntime.DERuntime
1. Makes a copy of the registry
2. Opens the copy and pull out everything has to do w. the
input string
3. Goes through the filtered info and searches for key
items that are always present in the strings I am
looking at
4. Filter those key items into array values that are pulled
out and used to find the location of the .dll
corresponding to the string name.
It works perfectly the first time through. After that, I can't seem to get the array values to reset, they keep adding on to the original, therefore, I never get the location of the next string. The script will tell me the name of the next string and give me the .dll location of the first string.
I had alot of echo statements in there showing me what the values of variables and arrays were at different palces but I took most of them out and just left the ReDim's at the bottom of the code b/c they seemed to be working when I checked them w/ echo's. Maybe my problem is somewhere else? I am not very advanced in vbs so could easily be missing something.
Please help, I think I just need another pair of eyes to see what I am missing.
Thank you sincerely for your time. It's very appreciated.
Find_Input.txt
Scripting.FileSystemObject
Microsoft.XMLDOM
MSXML2.DOMDocument
ConnectionInfo.clsConnectionInfo
ADODB.Recordset
ADODB.Command
ADODB.Connection
Scripting.Dictionary
MSWC.BrowserType
SMTPsvg.Mailer
CDONTS.NewMail
DERuntime.DERuntime
Code:
[COLOR=red] '*******FindString.vbs********* [/color]
Option Explicit
Dim objWS, objFSO, string, LogFile, ObjTextFile, strLine, arrKey, UseHive, strKeyPath
Dim sRegTmp, eRegLine, sRegKey, aRegFileLines, strValueName, strComputer
Dim objReadInput, strValue, Hive, inth, objReg, Return, arrLine2, Path, arrFinal
const HKEY_LOCAL_MACHINE = &H80000002
Const ForReading = 1, ForWriting = 2, ForAppending = 8
'***********************************************************
Set objWS = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set LogFile = ObjFSO.OpenTextFile("C:\Temp\Results.txt", ForWriting, True)
Set objReadInput = objFSO.OpenTextFile("C:\Sysapps\batch\Find_Input.txt", ForReading, True)
Do Until objReadInput.AtEndOfStream
string = objReadInput.ReadLine
If string = "DERuntime.DERuntime" Then
Wscript.Echo string & " ?"
Else
sRegTmp = objWS.Environment("Process")("Temp") & "\RegTmp.tmp "
objWS.Run "regedit /e /a " & sRegTmp, , True
With objFSO.GetFile(sRegTmp)
aRegFileLines = Split(.OpenAsTextStream(1, 0).Read(.Size), vbcrlf)
End With
For Each eRegLine in aRegFileLines
If InStr(1, eRegLine, "[", 1) > 0 Then sRegKey = eRegLine
If InStr(1, eRegLine, string, 1) > 0 Then
If sRegKey <> eRegLine Then
LogFile.WriteLine (vbcrlf & sRegKey) & vbcrlf & eRegLine
Else
LogFile.WriteLine (vbcrlf & sRegKey)
End If
End If
Next
'***************************************************
Dim arrLine, TempLine, arrPath
Set ObjTextFile = objFSO.OpenTextFile("C:\Temp\Results.txt", ForReading, True)
Do Until ObjTextFile.AtEndOfStream
strLine = ObjTextFile.ReadLine
If InStr(1, strLine, "}", 1) Then
If InStr(1, strLine, "CLSID",1) Then
If Instr(1, strLine, "ProgID", 1) Then
arrLine = Split(strLine, "}")
If InStr(1, arrLine(0), "]", 1) Then
arrLine2 = Split(arrLine(0), "]")
TempLine = arrLine2(0) & "\InprocServer32\"
arrPath = Split(TempLine, "[")
arrKey = Split(arrPath(1), "\")
Hive = arrKey(0)
For inth = 1 To UBound(arrKey)
Path = Path & arrKey(inth) & "\"
Next
Else
TempLine = arrLine(0) & "}\InprocServer32\"
arrPath = Split(TempLine, "[")
arrKey = Split(arrPath(1), "\")
Hive = arrKey(0)
For inth = 1 To UBound(arrKey)
Path = Path & arrKey(inth) & "\"
Next
Wscript.Echo Path
End If
End If
End If
End If
Loop
arrFinal = Split(Path, "\\")
Wscript.Echo arrFinal(0)
strKeyPath = arrFinal(0) & "\"
'***************************************************
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strValueName = ""
Return = objReg.GetExpandedStringValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)
If (Return = 0) And (Err.Number = 0) Then
WScript.Echo string & " is at: " & strValue
Else
Wscript.Echo "GetExpandedStringValue failed. Error = " & Err.Number
End If
Set Hive = Nothing
Set strValue = Nothing
Set strKeyPath = Nothing
ReDim arrFinal(-1)
ReDim arrKey(-1)
ReDim arrLine(-1)
ReDim arrLine2(-1)
End If
Loop
'***********************************************************