Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 476
  • Last Modified:

Query registry key and output results to a log file

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,_
strValueName,arrValues
 
For Each strValue In arrValues
    StdOut.WriteLine  strValue
Next

0
hpops
Asked:
hpops
  • 2
1 Solution
 
Erick37Commented:
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
Next

'close the file
logts.Close
0
 
hpopsAuthor Commented:
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.
0
 
Erick37Commented:
Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now