Freitag, 10. September 2010

Write Windows Patches to INI

This script was developed as a part of an self-written update engine within enteo Netinstall. It's purpose is, to scan a specified directory for Windows Patches and write them to a INI File. Only Patches, using the "Update.exe", should be added to the list. Other Patches, like MSXML or .NET SP should NOT be mentioned, because they are using MSI and therefore the parameters are not compatible.


'Script created by: Zierer, Markus
'Script created on: 2010 09 09
'
'This script performs file search operations and writes the results into an INI File.
'
'Prepare Variables
strComputer = "."
strINIFile = "c:\winxp\Temp\updates.ini"
strSection = "[updates]"

'Perform File Search Operation
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_LogicalFile Where Drive = 'c:' AND Path = '\\Winxp\\Temp\\Updates\\' AND FileName Like '%WindowsXP%'")

'Prepare Write to INI File Operation
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objINIFile = objFSO.CreateTextFile(strINIFile)

'Write Section to INI File
objINIFile.WriteLine(strSection)

'End Script if no files found
If colFiles.Count = 0 Then
objINIFile.WriteLine("1=")
Wscript.Quit
End If

'Write Keys and Values to INI File
intCounter = 1
intKey = intCounter

For Each objFile in colFiles
objINIFile.WriteLine(intKey & "=" & objFile.Name)
intKey = intCounter + 1
intCounter = intKey
Next

'Write an Empty Key to declare End of Section
objINIFile.WriteLine(intKey & "=")

Keine Kommentare:

Kommentar veröffentlichen