-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOfficeUpdatesCapture.vbs
More file actions
56 lines (56 loc) · 2.19 KB
/
Copy pathOfficeUpdatesCapture.vbs
File metadata and controls
56 lines (56 loc) · 2.19 KB
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
' ScriptCryptor Project Options Begin
' HasVersionInfo: No
' Companyname:
' Productname:
' Filedescription:
' Copyrights:
' Trademarks:
' Originalname:
' Comments:
' Productversion: 0. 0. 0. 0
' Fileversion: 0. 0. 0. 0
' Internalname:
' Appicon:
' AdministratorManifest: No
' ScriptCryptor Project Options End
Dim oMsi,oFso,oWShell
Dim Patches,SumInfo
Dim patch,record,msp
Dim qView
Dim sTargetFolder,sMessage
Const OFFICEID = "000-0000000FF1CE}"
Const PRODUCTCODE_EMPTY = ""
Const MACHINESID = ""
Const MSIINSTALLCONTEXT_MACHINE = 4
Const MSIPATCHSTATE_APPLIED = 1
Const MSIOPENDATABASEMODE_PATCHFILE = 32
Const PID_SUBJECT = 3 'Displayname
Const PID_TEMPLATES = 7 'PatchTargets
Set oMsi = CreateObject("WindowsInstaller.Installer")
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oWShell = CreateObject("Wscript.Shell")
'Create the target folder
sTargetFolder = oWShell.ExpandEnvironmentStrings("%temp%\")&"OfficeUpdates"
If Not oFso.FolderExists(sTargetFolder) Then oFso.CreateFolder sTargetFolder
sMessage = "Patches werden in das Temporäre Verzeichnis des ausführenden Benutzers kopiert." & vbCrLf & "Ein Windows Explorer-Fenster wird geöffnet, sobald der Vorgang abgeschlossen ist."
oWShell.Popup sMessage,20,"Office Updates Capture"
'Get all applied patches
Set Patches = oMsi.PatchesEx(PRODUCTCODE_EMPTY,MACHINESID,MSIINSTALLCONTEXT_MACHINE,MSIPATCHSTATE_APPLIED)
On Error Resume Next
'Enum the patches
For Each patch in Patches
If Not Err = 0 Then Err.Clear
'Connect to the patch file
Set msp = oMsi.OpenDatabase(patch.PatchProperty("LocalPackage"),MSIOPENDATABASEMODE_PATCHFILE)
Set SumInfo = msp.SummaryInformation
If Err = 0 Then
If InStr(SumInfo.Property(PID_TEMPLATES),OFFICEID)>0 Then
'Get the original patch name
Set qView = msp.OpenView("SELECT `Property`,`Value` FROM MsiPatchMetadata WHERE `Property`='StdPackageName'")
qView.Execute : Set record = qView.Fetch()
'Copy and rename the patch to the original file name
oFso.CopyFile patch.PatchProperty("LocalPackage"),sTargetFolder&"\"&record.StringData(2),TRUE
End If
End If 'Err = 0
Next 'patch
oWShell.Run "explorer /e,"&chr(34)&sTargetFolder&chr(34)