Inst_Patches

Kleines Script zum automatisierten Installieren von Patches und Hotfixes innerhalb der Installationsroutine von Office 2003
Nach vorher definierten Dateiendungen werden die unterschiedlichen Installationsroutinen gestartet.
Mit einer kleinen Pfadanpassung auch als Standalone-Loesung für laufende Patch-Installationen ueber SCCM
Verzeichnispfad (Pfad zur VBS-Datei und den im gleichen Ordner liegenden MSPs) muss als Parameter angegeben werden.

option explicit
'on error resume next

dim fso, wshell, oargs, activedir, activefile, fc, installtype, i, file, rc
dim parent, root, updatesfolder, logpfad
dim strcomputer, objWMIService, colProcesses, objProcess
Dim sngProcessTime, tmplog

set wshell = wscript.createobject("Wscript.shell")
set fso = wscript.createobject ("Scripting.FileSystemObject")


set oArgs=wscript.Arguments

if oArgs.Count 1 then
   wscript.echo VBCRLF & "! FEHLER !" & VBCRLF & "! Fehlender oder falscher Parameter !"
   wscript.quit
End if


set activedir = FSO.GetFolder(oargs(0))
activedir = activedir&"\Install\Updates"
set activedir = FSO.GetFolder(activedir)


set fc = activedir.files
installtype = array("msp","exe")

logpfad = "c:\logs\msi\"

for i =LBOUND(installtype) to UBOUND(installtype)
install installtype(i)
next


sub install(typ)
set tmplog = fso.CreateTextFile("c:\testdatei.txt", True)

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    
for each file in fc
    if lcase(fso.GetExtensionName(file.name) = "msp") then
    tmplog.writeline ("Installing " & file.name)
       rc = wshell.run("C:\WINDOWS\System32\msiexec.exe /p" & " " & activedir & "\" & file.name & " /q /L*v " & logpfad&file.name&".log",0,true)
    'elseif lcase(fso.GetExtensionName(file.name) = "exe") then
      'rc = wshell.run(activedir & "\" & file.name & " /q",0,true)
    end if

    Do
    tmplog.writeline ("Waiting for msiexec... <=="&  file.name)
      Set colProcesses = objWMIService.ExecQuery _
                 ("Select * from Win32_process where name =" & "'" & "msiexec.exe" & "'")

      wscript.sleep 5000


      loop until colprocesses.count=1

next
tmplog.close
end sub

  • Mittwoch, 14 März 2018

Leave a comment

You are commenting as guest.