1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| Set fso = CreateObject("Scripting.FileSystemObject")
Set Ts1 = fso.OpenTextFile("C:\Users\nomsrv.txt")
do while not ts1.AtEndOfStream
strComputer=ts1.ReadLine
Set Ts2 = fso.CreateTextFile("C:\Users\" & strComputer & ".txt", True)
Const HKLM = &h80000002
Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
objCtx.Add "__ProviderArchitecture", 32
objCtx.Add "__RequiredArchitecture", TRUE
Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
Set objServices = objLocator.ConnectServer(strComputer,"root\default","","",,,,objCtx)
Set objStdRegProv = objServices.Get("StdRegProv")
Ts2.WriteLine vbNewLine & strComputer & vbNewLine
Ts2.WriteLine "32-bit Applications"
Ts2.WriteLine "-------------------"
Call GetApplications
objCtx.Add "__ProviderArchitecture", 64
objCtx.Add "__RequiredArchitecture", TRUE
Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
Set objServices = objLocator.ConnectServer(strComputer,"root\default","","",,,,objCtx)
Set objStdRegProv = objServices.Get("StdRegProv")
Ts2.WriteLine "64-bit Applications"
Ts2.WriteLine "-------------------"
On Error resume next
Call GetApplications
loop
WScript.quit
Sub GetApplications
' Use ExecMethod to call the GetStringValue method
Set Inparams = objStdRegProv.Methods_("EnumKey").Inparameters
Inparams.Hdefkey = HKLM
Inparams.Ssubkeyname = "Software\Microsoft\Windows\CurrentVersion\Uninstall\"
set Outparams = objStdRegProv.ExecMethod_("EnumKey", Inparams,,objCtx)
For Each strSubKey In Outparams.snames
Set Inparams = objStdRegProv.Methods_("GetStringValue").Inparameters
Inparams.Hdefkey = HKLM
Inparams.Ssubkeyname = "Software\Microsoft\Windows\CurrentVersion\Uninstall\" & strSubKey
Inparams.Svaluename = "DisplayName"
set Outparams = objStdRegProv.ExecMethod_("GetStringValue", Inparams,,objCtx)
if ("" & Outparams.sValue) = "" then
Ts2.WriteLine strSubKey
Else
Ts2.WriteLine Outparams.SValue
End iF
Inparams.Svaluename = "QuietDisplayName"
set Outparams = objStdRegProv.ExecMethod_("GetStringValue", Inparams,,objCtx)
Ts2.WriteLine "Outparams.SValue"
Next
End Sub
Ts2.Close
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Users\" & strComputer &", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If InStr(strLine, "KB") = 0 Then
strNewContents = strNewContents & strLine & vbCrLf
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile("C:\Users\" & strComputer &", ForWriting)
objFile.Write strNewContents
objFile.Close |
Partager