#Customizable Information #The appname variable cannot be empty, please insert name of software $appname = "" #Insert your uninstall and install silent switches below $uninstallswitches = "" $installswitches = "" #If you are using an MSI file please insert the location of the file in the MSIFile variable. Please insert all EXE installs into the EXEfile variable $MSIfile = "" $EXEfile = "" #Insert your transform file location in the transformfile variable. This is not a required field $transformfile = "" if ($transformfile) { $transforms = "TRANSFORMS=`"$transformfile`"" } else { $transforms = "" } $toolversion = "V1" if ($MSIfile -or $EXEfile) { if ($appname) { #Retrieves Uninstall Strings $32bit = get-itemproperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, UninstallString, PSChildName | Where-Object { $_.DisplayName -match "^*$appname*"} $64bit = get-itemproperty 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, UninstallString, PSChildName | Where-Object { $_.DisplayName -match "^*$appname*"} if ($MSIfile) { $filecheck = Test-Path -LiteralPath "$MSIfile" if($filecheck -eq $true) { #IF YOU SPECIFIED AN MSI INSTALL FILE if ($64bit -eq "" -or $64bit.count -eq 0) { switch ($32bit.DisplayName.count) { 0 { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green ; Write-Host "Installing $appname" Start-Process -Filepath "msiexec.exe" -ArgumentList "/i `"$MSIfile`" $transforms $installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } 1 { if ($32bit -match "msiexec.exe") { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname" $uninstall = $32bit.UninstallString -replace 'msiexec.exe /i','msiexec.exe /x' cmd /c ("$uninstall" + ' ' + $uninstallswitches) Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" Start-Sleep -s 4 Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname" Start-Process -Filepath "msiexec.exe" -ArgumentList "/i `"$MSIfile`" $transforms $installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } else { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname" $uninstall = $32bit.UninstallString cmd /c ("$uninstall" + ' ' + $uninstallswitches) Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" Start-Sleep -s 4 Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname" Start-Process -Filepath "msiexec.exe" -ArgumentList "/i `"$MSIfile`" $transforms $installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } } default { Write-Host "Found multiple installations" -ForegroundColor Red exit } } } else { switch ($64bit.DisplayName.count) { 0 { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green ; Write-Host "Installing $appname" Start-Process -Filepath "msiexec.exe" -ArgumentList "/i `"$MSIfile`" $transforms $installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } 1 { if ($64bit -match "msiexec.exe") { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname" $uninstall = $64bit.UninstallString -replace 'msiexec.exe /i','msiexec.exe /x' cmd /c ("$uninstall" + ' ' + $uninstallswitches) Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" Start-Sleep -s 4 Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname" Start-Process -Filepath "msiexec.exe" -ArgumentList "/i `"$MSIfile`" $transforms $installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } else { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname" $uninstall = $64bit.UninstallString cmd /c ("$uninstall" + ' ' + $uninstallswitches) Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" Start-Sleep -s 4 Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname" Start-Process -Filepath "msiexec.exe" -ArgumentList "/i `"$MSIfile`" $transforms $installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } } default { Write-Host "Found multiple installations." -ForegroundColor Red exit } } } } else { Clear-Host Write-Host "Error - Cannot find your MSI file" -ForegroundColor Red } } else { $filecheck = Test-Path -LiteralPath "$EXEfile" if($filecheck -eq $true) { #IF YOU SPECIFIED AN EXE INSTALL FILE if ($64bit -eq "" -or $64bit.count -eq 0) { switch ($32bit.DisplayName.count) { 0 { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green ; Write-Host "Installing $appname" Start-Process -Filepath "$EXEfile" -ArgumentList "$installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } 1 { if ($32bit -match "msiexec.exe") { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname" $uninstall = $32bit.UninstallString -replace 'msiexec.exe /i','msiexec.exe /x' cmd /c ("$uninstall" + ' ' + $uninstallswitches) Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" Start-Sleep -s 4 Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname" Start-Process -Filepath "$EXEfile" -ArgumentList "$installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } else { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname" $uninstall = $32bit.UninstallString Start-Process -Filepath "$uninstall" -ArgumentList "$uninstallswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" Start-Sleep -s 4 Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname" Start-Process -Filepath "$EXEfile" -ArgumentList "$installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } } default { Write-Host "Found multiple installations" -ForegroundColor Red exit } } } else { switch ($64bit.DisplayName.count) { 0 { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green ; Write-Host "Installing $appname" Start-Process -Filepath "$EXEfile" -ArgumentList "$installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } 1 { if ($64bit -match "msiexec.exe") { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname" $uninstall = $64bit.UninstallString -replace 'msiexec.exe /i','msiexec.exe /x' cmd /c ("$uninstall" + ' ' + $uninstallswitches) Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" Start-Sleep -s 4 Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname" Start-Process -Filepath "$EXEfile" -ArgumentList "$installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } else { Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname" $uninstall = $64bit.UninstallString Start-Process -Filepath "$uninstall" -ArgumentList "$uninstallswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" Start-Sleep -s 4 Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname" Start-Process -Filepath "$EXEfile" -ArgumentList "$installswitches" -wait Clear-Host Write-Host "***Uninstall and Install Tool $toolversion***" -ForegroundColor Green; Write-Host "***********************************" -ForegroundColor Green; Write-Host "Uninstalling $appname - Done" ; Write-Host "Installing $appname - Done" Start-Sleep -s 4 } } default { Write-Host "Found multiple installations." -ForegroundColor Red exit } } } } else { Clear-Host Write-Host "Error - Cannot find EXE file" -ForegroundColor Red } } } else { Clear-Host Write-Host "Error - Appname variable is empty." -ForegroundColor Red } } else { Clear-Host Write-Host "Error - Please provide install file in the MSIfile or EXEfile variable" -ForegroundColor Red }