troubleshooting Question

Reading keys in a .reg file and output to .csv

Avatar of NanohurtzChrome
NanohurtzChrome asked on
Visual Basic ClassicVB ScriptMicrosoft Excel
13 Comments1 Solution772 ViewsLast Modified:
I have this snippet that does the following

1. Opens a .reg file
2. Scans for strings after the "DisplayName" and DisplayVersion" headers
For every instance of "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" the script should loop and find the two headers before proceeding to the next instance of "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

3. Outputs the file to .csv

Problem here is that the script appears to be reading the input .reg file but nothing appears in the .csv file. I'm also wondering if the script compensates for instances where DisplayVersion is not available for a given application

 I've included the .vbs and .reg file for testing

set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.OpenTextFile("ST-PI.reg")
set objOutput = objFSO.CreateTextFile("ST-PI.csv")

Do while not objFile.AtEndOfStream
        strCurrentLine = objFile.ReadLine
        If Instr(strCurrentLine,"DisplayName") then
                strName = Replace(Split(strCurrentLine,"=")(1),chr(34),"")
        End if
        If Instr(strCurrentLine,"DisplayVersion") then
                strVersion = Replace(Split(strCurrentLine,"=")(1),chr(34),"")
                objOutput.WriteLine strName &";" &strVersion
        End if

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros