Corrected

pull/257/head
KnifMelti 2023-01-01 01:58:43 +01:00
parent 637f2108bb
commit 6659404bd7
1 changed files with 10 additions and 8 deletions

View File

@ -19,6 +19,7 @@ function Uninstall-ModsApp ($App) {
foreach ($obj in $InstalledSoftware){ foreach ($obj in $InstalledSoftware){
if ($obj.GetValue('DisplayName') -like $App) { if ($obj.GetValue('DisplayName') -like $App) {
$UninstallString = $obj.GetValue('UninstallString') $UninstallString = $obj.GetValue('UninstallString')
$CleanedUninstallString = $UninstallString.Trim([char]0x0022)
if ($UninstallString -like "MsiExec.exe*") { if ($UninstallString -like "MsiExec.exe*") {
$ProductCode = Select-String "{.*}" -inputobject $UninstallString $ProductCode = Select-String "{.*}" -inputobject $UninstallString
$ProductCode = $ProductCode.matches.groups[0].value $ProductCode = $ProductCode.matches.groups[0].value
@ -39,16 +40,16 @@ function Uninstall-ModsApp ($App) {
Start-Process $Command -ArgumentList $Parameter -Wait Start-Process $Command -ArgumentList $Parameter -Wait
} }
else { else {
if ((Test-Path "$UninstallString")) { if ((Test-Path $CleanedUninstallString)) {
$NullSoft = Select-String -Path $UninstallString.Trim([char]0x0022) -Pattern "Nullsoft" $NullSoft = Select-String -Path $CleanedUninstallString -Pattern "Nullsoft"
} }
if ($NullSoft) { if ($NullSoft) {
#NSIS x64 Installer #NSIS x64 Installer
Start-Process $UninstallString -ArgumentList "/S" -Wait Start-Process $UninstallString -ArgumentList "/S" -Wait
} }
else { else {
if ((Test-Path "$UninstallString")) { if ((Test-Path $CleanedUninstallString)) {
$Inno = Select-String -Path $UninstallString.Trim([char]0x0022) -Pattern "Inno Setup" $Inno = Select-String -Path $CleanedUninstallString -Pattern "Inno Setup"
} }
if ($Inno) { if ($Inno) {
#Inno x64 Installer #Inno x64 Installer
@ -74,6 +75,7 @@ function Uninstall-ModsApp ($App) {
foreach ($obj in $InstalledSoftware){ foreach ($obj in $InstalledSoftware){
if ($obj.GetValue('DisplayName') -like $App) { if ($obj.GetValue('DisplayName') -like $App) {
$UninstallString = $obj.GetValue('UninstallString') $UninstallString = $obj.GetValue('UninstallString')
$CleanedUninstallString = $UninstallString.Trim([char]0x0022)
if ($UninstallString -like "MsiExec.exe*") { if ($UninstallString -like "MsiExec.exe*") {
$ProductCode = Select-String "{.*}" -inputobject $UninstallString $ProductCode = Select-String "{.*}" -inputobject $UninstallString
$ProductCode = $ProductCode.matches.groups[0].value $ProductCode = $ProductCode.matches.groups[0].value
@ -94,16 +96,16 @@ function Uninstall-ModsApp ($App) {
Start-Process $Command -ArgumentList $Parameter -Wait Start-Process $Command -ArgumentList $Parameter -Wait
} }
else { else {
if ((Test-Path "$UninstallString")) { if ((Test-Path $CleanedUninstallString)) {
$NullSoft = Select-String -Path $UninstallString.Trim([char]0x0022) -Pattern "Nullsoft" $NullSoft = Select-String -Path $CleanedUninstallString -Pattern "Nullsoft"
} }
if ($NullSoft) { if ($NullSoft) {
#NSIS x86 Installer #NSIS x86 Installer
Start-Process $UninstallString -ArgumentList "/S" -Wait Start-Process $UninstallString -ArgumentList "/S" -Wait
} }
else { else {
if ((Test-Path "$UninstallString")) { if ((Test-Path $CleanedUninstallString)) {
$Inno = Select-String -Path $UninstallString.Trim([char]0x0022) -Pattern "Inno Setup" $Inno = Select-String -Path $CleanedUninstallString -Pattern "Inno Setup"
} }
if ($Inno) { if ($Inno) {
#Inno x86 Installer #Inno x86 Installer