Query registry key and output results to a log file

Posted on 2005-03-30
Medium Priority
Last Modified: 2011-08-18
This should be an easy one but I'm having trouble with it.

This script is working for me, however I need to have a log file generated on the value it finds in the registry. The value is a "Mutli-string" key.

I have a way to run this at login and would like the script to append the results it finds to a network server. I'd also prefer it create the log file if it did not exist otherwise append to it.

Thanks for any help with this one

const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\Setup"
strValueName = "OEMDuplicatorString"
oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,_
For Each strValue In arrValues
    StdOut.WriteLine  strValue

Question by:hpops
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 32

Accepted Solution

Erick37 earned 1400 total points
ID: 13661931
Example of writing to a text file:


oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath, strValueName,arrValues

'create the FileSystemObject
Set fso = CreateObject("scripting.filesystemobject")
'Open the data file for appending
'fso.OpenTextFile "c:\reglog.txt", ForAppending, True, TristateFalse
Set logts = fso.OpenTextFile("c:\reglog.txt", 8, -1, 0)

For Each strValue In arrValues
    'StdOut.WriteLine strValue
    'append to file
    logts.WriteLine strValue

'close the file

Author Comment

ID: 13663298
Thank you very much. I have combined these two sections together and it's working great. I appreciate your fast response and am increasing the points for this question.
LVL 32

Expert Comment

ID: 13666531

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question