General discussion

Locked

WMI: Output to a file

By psvoboda ·
HI, Does anyone knows how to output the data to a file in the script below? I tried to find info on this but so far no luck. Thanks.
-------------------------------------
Option Explicit

Dim strComputer, strKey, strSubKey
Dim objRegistry
Dim arrSubKeys()
Dim strDisplayName, strDisplayVersion, strInstallLocation

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

'*
'* CALLOUT A
'*
Set objRegistry = GetObject("winmgmts:" & _
"{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

'*
'* CALLOUT B
'*
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys

'*
'* CALLOUT C
'*
On Error Resume Next
For Each strSubKey In arrSubKeys

objRegistry.GetStringValue HKEY_LOCAL_MACHINE, _
strKey & "\" & strSubKey, _
"DisplayName", _
strDisplayName

objRegistry.GetStringValue HKEY_LOCAL_MACHINE, _
strKey & "\" & strSubKey, _
"DisplayVersion", _
strDisplayVersion

objRegistry.GetStringValue HKEY_LOCAL_MACHINE, _
strKey & "\" & strSubKey, _
"InstallLocation", _
strInstallLocation

WScript.Echo strSubKey
WScript.Echo String(Len(strSubKey), "-")
WScript.Echo "Display name: " & strDisplayName
WScript.Echo "Display version: " & strDisplayVersion
WScript.Echo "Install location: " & strInstallLocation
WScript.Echo

strDisplayName = vbEmpty
strDisplayVersion = vbEmpty
strInstallLocation = vbEmpty

Next

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by pryzhkov In reply to WMI: Output to a file

There are two solutions here. You can just redirect Your output to a file when You are starting Your script from command line. This is the simple one. The second solution is to add some code to Your script. something like:

set fso = CreateObject("Scripting.FileSystemObject")
set alog = fso.CreateTextFile("C:\result.txt", True)
...
alog.WriteLine strSubKey
alog.WriteLine String(Len(strSubKey), "-")
alog.WriteLine "Display name: " & strDisplayName
alog.WriteLine "Display version: " & alog.WriteLine strDisplayVersion
alog.WriteLine "Install location: " & strInstallLocation
...
alog = Nothing
set

Collapse -

by psvoboda In reply to

Thanks for your help!!

Collapse -

by psvoboda In reply to WMI: Output to a file

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums