On Error Resume Next
Dim arrSubKeys, arrSubKeys2
Dim objFSO, objShell, objFile, objReg, objConn
Dim strComputer, strKeyPath, strNewSource
Dim strWorkstationName, strDBPath, strSubKey, strSubKey2(), strKeyPath02, strRetValue00
Dim strRetValue01, strRetValue02, strRetValNew02, strRetValNew03, strRetValNew04, strRetValNew05, strRetValNew06, strRetValNew07, strRetValNew08, strRetValNew09, strRetValue10, strRetValNew10, strRetValNew11, strRetValNew12
Const HKCR = &H80000000 'HKEY_CLASSES_ROOT
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Const ForReading = 1, ForWriting = 2, ForAppEnding = 8
'
' Leaving strNewSource will result in no search path updating.
' Currently DO NOT EDIT these.
strNewSource = ""
strNewRTMSource = ""
' Define string values
strComputer = "."
strSQLName = "Microsoft SQL"
strSQLName2k8 = "SQL Server"
strDotNetName = "Microsoft .NET"
strVStudioName = "Microsoft Visual Studio"
strKeyPath = "Installer\Products"
strKeyPath2 = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products"
strNValue00 = "ProductName"
strNValue01 = "PackageName"
strNValue02 = "LastUsedSource"
strNValue03 = "InstallSource"
strNValue04 = "LocalPackage"
strNValue05 = "DisplayVersion"
strNValue06 = "InstallDate"
strNValue07 = "UninstallString"
strNValue08 = "PackageCode"
strNValue09 = "MediaPackage"
strNValue10 = "InstallSource"
strNValue11 = "AllPatches"
strNValue12 = "NoRepair"
If WScript.arguments.count <> 1 Then
WScript.echo "Usage: cscript " & WScript.scriptname & " outputfilename.txt"
WScript.quit
End If
'--Setup the output file
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtFile = fso.OpenTextFile(WScript.arguments(0), ForWriting, True)
If err.number <> 0 Then
WScript.echo "Error 0x" & myHex(err.number,8) & ": " & err.source & " - " & err.description
WScript.quit
End If
txtFile.writeline "Products installed on the local system"
txtFile.writeline " "
txtFile.writeline " "
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")
'--Set up the registry provider.
Set objReg = GetObject("winmgmts:\\" & strComputer & _
"\root\default:StdRegProv")
Set wiInstaller = CreateObject("WindowsInstaller.Installer")
'--Enumerate the "installer\products" key on HKCR
objReg.EnumKey HKCR, strKeyPath, arrSubKeys
For Each strSubKey In arrSubKeys
strKeyPath02 = "Installer\Products\" & strSubKey & "\SourceList"
strKeyPath03 = "Installer\Products\" & strSubKey & "\SourceList\Media"
strProduct01 = "Installer\Products\" & strSubKey
strInstallSource = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" & strSubKey & "\InstallProperties\"
strInstallSource2 = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" & strSubKey & "\patches\"
strInstallSource3 = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Patches"
strInstallSource4 = "Installer\Patches\"
strInstallSource5 = "SOFTWARE\Classes\Installer\Patches\"
objReg.GetStringValue HKCR, strProduct01, strNValue00, strRetValue00
objReg.GetStringValue HKCR, strKeyPath02, strNValue01, strRetValue01
objReg.GetStringValue HKCR, strKeyPath02, strNValue02, strRetValue02
strRetValNew02 = Mid(strRetValue02, 5)
objReg.GetStringValue HKCR, strKeyPath03, strNValue09, strRetValue09
strRetValue10 = strNewRTMSource & strRetValue09
objReg.GetStringValue HKLM, strInstallSource, strNValue03, strRetValNew03
objReg.GetStringValue HKLM, strInstallSource, strNValue04, strRetValNew04
objReg.GetStringValue HKLM, strInstallSource, strNValue05, strRetValNew05
objReg.GetStringValue HKLM, strInstallSource, strNValue06, strRetValNew06
objReg.GetStringValue HKLM, strInstallSource, strNValue07, strRetValNew07
objReg.GetStringValue HKLM, strInstallSource, strNValue10, strRetValNew10
objReg.GetStringValue HKLM, strInstallSource, strNValue12, strRetValNew12
objReg.GetStringValue HKLM, strInstallSource2, strNValue11, strRetValNew11
' Pull the Product Code from the Uninstall String
strProdCode = strRetValNew07
ProdCodeLen = Len(strProdCode)
ProdCodeLen = ProdCodeLen - 14
strRetValNew08 = Right(strProdCode, ProdCodeLen)
If instr(1, strRetValue00, strSQLName, 1) or instr(1, strRetValue00, strSQLName2k8, 1) Then
txtFile.writeline "ProductName: " & strRetValue00
txtFile.writeline "Product Code: " & strRetValNew08
txtFile.writeline "Version: " & strRetValNew05
txtFile.writeline "Registry Path: "
txtFile.writeline " HKEY_CLASSES_ROOT\" & strKeyPath02
txtFile.writeline "Package: " & strRetValue01
txtFile.writeline "Install Source: " & strRetValue10
txtFile.writeline "Last Used Source: " & strRetValue02
'txtFile.writeline "Does this file on this path exist? " & strRetValNew02 & "\" & strRetValue01
If fso.fileexists(strRetValNew02 & "\" & strRetValue01) Then
txtFile.writeline " Package exists on the Last Used Source path."
Else
txtFile.writeline " Package does not exist on the Last Used Source path."
' Fix the LastUsedSource by adding source and Forcing search of list
If strNewSource <> "" Then
txtFile.writeline " New Install Source Path Added: " & strNewSource
wiInstaller.AddSource strRetValNew08, "", strNewSource
Else
If strNewRTMSource <> "" Then
wiInstaller.AddSource strRetValNew08, "", strNewRTMSource
txtFile.writeline " Forcing SourceList Resolution For: " & strRetValNew08
wiInstaller.ForceSourceListResolution strRetValNew08, ""
End If
End If
End If
txtFile.writeline "Installer Cache File: " & strRetValNew04
If fso.fileexists(strRetValNew04) Then
txtFile.writeline " Package exists in the Installer cache."
Else
txtFile.writeline " Package does not exist in the Installer cache."
End If
txtFile.writeline "Install Date: " & strRetValNew06
txtFile.writeline " "
txtFile.writeline "Patches Installed "
txtFile.writeline " "
txtFile.writeline "AllPatches: " & strRetValNew11
txtFile.writeline " "
err.clear
objReg.EnumKey HKLM, strInstallSource2, arrSubKeys2
uUpperBounds = UBound(arrSubKeys2,1)
If err.number = 0 Then
For Each strSubKey2 in arrSubKeys2
' WScript.echo "value = " & strSubKey2
txtfile.writeline " Patch Key under: "
txtFile.writeline " HKEY_CLASSES_ROOT\Installer\Patches\" & strSubKey2
objReg.GetStringValue HKLM, strInstallSource2 & "\" & strSubKey2 & "\", "DisplayName", strResultDisplayName
txtFile.writeline " DisplayName = " & strResultDisplayName
txtFile.writeline " The both Last Used Source should have same values:"
objReg.GetStringValue HKCR, strInstallSource4 & strSubKey2 & "\SourceList\", "LastUsedSource", strResultLastUsed
txtFile.writeline " Last Used Source = " & strResultLastUsed
objReg.GetStringValue HKLM, strInstallSource5 & strSubKey2 & "\SourceList\", "LastUsedSource", strResultLastUsed
txtFile.writeline " Last Used Source = " & strResultLastUsed
objReg.GetStringValue HKLM, strInstallSource2 & "\" & strSubKey2 & "\", "Installed", strResultInstalled
txtFile.writeline " Install Date = " & strResultInstalled
'txtfile.writeline strInstallSource3 & "\" & strSubKey2 & "\" & "LocalPackage"
objReg.GetStringValue HKLM, strInstallSource3 & "\" & strSubKey2 & "\", "LocalPackage", strResultLocalPackage
txtFile.writeline " Installer Cache File Path = " & strResultLocalPackage
' WScript.echo "Installer = " & strResultLocalPackage
If strResultLocalPackage <> "" Then
If fso.fileexists(strResultLocalPackage) Then
txtFile.writeline " Package exists in the Installer cache."
txtFile.writeline " "
Else
txtFile.writeline " Package does not exist in the Installer cache."
txtFile.writeline " "
End If
Else
txtFile.writeline " "
End If
next
Else
txtfile.writeline " "
txtfile.Writeline " No Patches Found"
End If
txtFile.writeline " "
txtFile.writeline "==============================================================="
txtFile.writeline "*** WARNING **** This command line is not meant to be used under normal conditions."
txtFile.writeline " "
txtFile.writeline "Un-install string if exists = " & strRetValNew07
txtFile.writeline " "
txtFile.writeline "==============================================================="
txtFile.writeline " "
End If
Next
txtFile.Close
Set txtFile = Nothing
Set fso = Nothing
===================================================================
Copy the script into a notepad and save as .vbs file format.
Now call the vbs file in command prompt.
For Example:D:\temp\MSI.VBS d:\temp\MSIoptput.txt and press enter.
In the output file you will find all the MSI/MSP missing on the server and you have to copied the MSI/MSP manually to C:\Windows\Installer folder.
No comments:
Post a Comment