show matching apps that cannot be uninstalled
This commit is contained in:
+13
-3
@@ -18,6 +18,12 @@ Foreach ( $reg in $UNINSTALL_KEYS ) {
|
||||
## Get the display name of the app
|
||||
$DISPLAY_NAME = $REG_PROPERTY.DisplayName
|
||||
|
||||
# Get the UninstallString
|
||||
$UNINSTALLSTRING = $REG_PROPERTY.UninstallString
|
||||
|
||||
# Get the ModifyPath
|
||||
$MODIFYPATH = $REG_PROPERTY.ModifyPath
|
||||
|
||||
## Make sure the DisplayName matches what we're looking for
|
||||
If ( $DISPLAY_NAME -ilike $APP_NAME ) {
|
||||
## Make sure the software was installed using an MSI
|
||||
@@ -26,15 +32,16 @@ Foreach ( $reg in $UNINSTALL_KEYS ) {
|
||||
If ( $REG_PROPERTY.InstallLocation ) { $INSTALL_LOCATION = $REG_PROPERTY.InstallLocation }
|
||||
|
||||
## Get the product code from the UninstallString
|
||||
If ( $REG_PROPERTY.UninstallString ) { $PRODUCT_CODE = $(Get-GUIDFromMSIUninstallString -str $REG_PROPERTY.UninstallString) }
|
||||
If ( $UNINSTALLSTRING ) { $PRODUCT_CODE = $(Get-GUIDFromMSIUninstallString -str $UNINSTALLSTRING) }
|
||||
|
||||
## Get the product code from the ModifyPath
|
||||
ElseIf ( $REG_PROPERTY.ModifyPath ) { $PRODUCT_CODE = $(Get-GUIDFromMSIUninstallString -str $REG_PROPERTY.ModifyPath) }
|
||||
ElseIf ( $MODIFYPATH ) { $PRODUCT_CODE = $(Get-GUIDFromMSIUninstallString -str $MODIFYPATH) }
|
||||
|
||||
## Uninstall the app
|
||||
If ( $PRODUCT_CODE ) {
|
||||
LogMsg "Uninstalling ${DISPLAY_NAME} ${PRODUCT_CODE}"
|
||||
Try { Start-Process -FilePath "msiexec.exe" -ArgumentList "/X${PRODUCT_CODE} /qn /norestart" -Wait }
|
||||
$args = '/X{' + $PRODUCT_CODE + '} /qn /norestart'
|
||||
Try { Start-Process -FilePath "msiexec.exe" -ArgumentList $args -Wait }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
|
||||
If ( $INSTALL_LOCATION ) {
|
||||
@@ -46,5 +53,8 @@ Foreach ( $reg in $UNINSTALL_KEYS ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Else {
|
||||
LogMsg "`nFound ${DISPLAY_NAME}, but it cannot be uninstalled by this script`nUninstallString: ${UNINSTALLSTRING}`n"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user