Hallo Lashandan,
das Performance Problem liegt an der Abfrage der Installierten Software via wmi query der Win32_product Klasse. Diese dauert immer sehr lange! Aufgepasst es kann unter umständer auch passieren, dass die Software sich repariert, da mit einer query auf Win32_product auch ein consistency check gemacht wird.
Hier ein auszug von Microsoft:
Warning Win32_Product is not query optimized. Queries such as "select * from Win32_Product where (name like 'Sniffer%')" require WMI to use the MSI provider to enumerate all of the installed products and then parse the full list sequentially to handle the “where” clause. This process also initiates a consistency check of packages installed, verifying and repairing the install. With an account with only user privileges, as the user account may not have access to quite a few locations, may cause delay in application launch and an event 11708 stating an installation failure. For more information, see KB Article 794524.
Eine andere Methode, die ich bei der Software Paketierung verwende ist, die uninstall registry keys der installierten Software abzufragen:
(x86)
HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\
(x64)
HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\
Hier einmal ein Auszug aus einem Powershell-Script, vielleicht kannst du ja etwas von gebrauchen:
# Version of the application to detect
[version]$InstallerVersion = ''
# Name of the application to detect
[string]$AppName = ''
# 32-Bit Detection
$32BitApp = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {
($_.DisplayName -notlike "Windows *") `
-and ($_.DisplayName -notlike "") `
-and ($_.DisplayName -notlike "Security*") `
-and ($_.DisplayName -notlike "Update*") `
-and ($_.DisplayName -notlike "Service Pack*") `
-and ($_.DisplayName -notlike "Definition*") `
-and ($_.displayname -like $AppName)
}
foreach ($item in $32BitApp) {
[version]$InstalledVersion = $item.DisplayVersion
if ($InstalledVersion -ge $InstallerVersion) {
Write-Output "Installed"
}
else {
}
}
# 64-Bit Detection
$64BitApp = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {
($_.DisplayName -notlike "Windows *") `
-and ($_.DisplayName -notlike "") `
-and ($_.DisplayName -notlike "Security*") `
-and ($_.DisplayName -notlike "Update*") `
-and ($_.DisplayName -notlike "Service Pack*") `
-and ($_.DisplayName -notlike "Definition*") `
-and ($_.displayname -like $AppName) }
foreach ($item in $64BitApp) {
[version]$InstalledVersion = $item.DisplayVersion
if ($InstalledVersion -ge $InstallerVersion) {
Write-Output "Installed"
}
else {
}
}
Alles anzeigen
Viele Grüße,
Digitalkarl