Description
Determines whether Microsoft Office products were installed through per-user or per-computer mode.
Script Code
' Copyright (c) 2005, Microsoft Corporation
Const cOffice = "78E1-11D2-B60F-006097C998E7}.6000-11D3-8CFE-0050048383C9}.6000-11D3-8CFE-0150048383C9}.BDCA-11D1-B7AE-00C04FB92F3D}.6D54-11D4-BEE3-00C04F990354}"
Const cReadOnly = 0: Const cForWriting = 2: Const cPID_WORDCOUNT = 15
Const cHKEY_CLASSES_ROOT = &H80000000: Const iProdLen = 28
On Error Resume Next
Set msi = CreateObject("WindowsInstaller.Installer")
If Err.Number = 0 Then
'Initialize/Reset it to empty string
sOutput = vbNullString
'Create the shell object to gather computername and temp directory information
Set wshl = CreateObject("WScript.Shell")
sComputerName = wshl.ExpandEnvironmentStrings("%COMPUTERNAME%")
sTempDir = wshl.ExpandEnvironmentStrings("%TEMP%")
sPathOutputFolder = sTempDir & "\"
'Write computername to output string
sOutput = "Computername: " & sComputerName & vbCrLf & vbCrLf
'Iterate through all installed PRODUCTS based on Windows Installer
For Each prod In msi.Products
'Check if the current product is within the Office family
If InStr(cOffice, UCase(Right(prod, iProdLen))) > 0 Then
'Gather information from ProductInfo
sProductName = msi.ProductInfo(prod, "ProductName")
If msi.ProductInfo(prod, "AssignmentType") = 0 Then
SAssignment = "Installation Type = ""Per-User"" mode."
Else
SAssignment = "Installation Type = ""Per-Computer"" mode."
End If
'Write product information to output string
sOutput = sOutput & sProductName & vbCrLf & SAssignment & vbCrLf & vbCrLf
End If
Next
'Clean up objects
Set msi = Nothing
'Create FileSystemObject for logfile generation
Set fso = CreateObject("Scripting.FileSystemObject")
Set fileOutput = fso.OpenTextFile(sPathOutputFolder & "\" & sComputerName & ".txt", cForWriting, True, True)
fileOutput.Write sOutput
fileOutput.Close
MsgBox "Logfile has been created as " & sPathOutputFolder & sComputerName & ".txt"
wshl.Run sPathOutputFolder & sComputerName & ".txt"
Set wshl = Nothing
'Clean up FileSystemObject
Set fso = Nothing
End If
For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.
Disclaimer
The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.