We help IT Professionals succeed at work.
Get Started

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

771 Views
Last Modified: 2013-11-25
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
Loop

Open in new window

ST-PI.reg
Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2008
Commented:
This problem has been solved!
Unlock 1 Answer and 13 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE