Upload files to "App Uninstall Scripts"
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<#
|
||||
Author: Gabe Kerntke
|
||||
Date: 07-22-2024
|
||||
|
||||
.Synopsis
|
||||
Script checks to see if Chrome is installed, if installed it will uninstall
|
||||
|
||||
.Modified
|
||||
2024-07-22 (GabeK) - Original script created
|
||||
|
||||
#>
|
||||
|
||||
# Variables #
|
||||
$AppName = "UltraVnc"
|
||||
|
||||
# Functions #
|
||||
|
||||
#Function checks for 32 or 64 bit processor and then pulls list of applications accordingly
|
||||
Function Get-Software ($CPU = $ENV:PROCESSOR_ARCHITECTURE) {
|
||||
If ($CPU -eq 'AMD64') {
|
||||
$64bit = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*
|
||||
$32bit = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
|
||||
$32bit + $64bit
|
||||
}
|
||||
Else { Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* }
|
||||
}
|
||||
|
||||
Function ExitCode {
|
||||
If ($ExitCode -eq 0) {
|
||||
Write-Host "$AppName uninstalled successfully."
|
||||
}
|
||||
ElseIf ($ExitCode -eq 3010) {
|
||||
Write-Host "$AppName successfully uninstalled, but requires a reboot to complete."
|
||||
}
|
||||
Else {
|
||||
Write-Host `n
|
||||
Start-Sleep 5
|
||||
Write-Host "$AppName failed to uninstall. Exit Code:" + $ExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Function Uninstall-App {
|
||||
$Run = Start-Process "C:\program files\UltraVNC\unins000.exe" -ArgumentList "/VERYSILENT /NORESTART" -Wait -PassThru
|
||||
$ExitCode = ($Run).ExitCode
|
||||
ExitCode
|
||||
}
|
||||
|
||||
# Script start #
|
||||
|
||||
#Check to see if program is installed
|
||||
$Applist = Get-Software | Where-Object { $_.DisplayName -like "*$AppName*" }
|
||||
If ($Applist.DisplayName -like "*$AppName*") {
|
||||
Uninstall-App
|
||||
}
|
||||
Else {
|
||||
Write-Host "$AppName is not installed, exiting script"
|
||||
}
|
||||
Reference in New Issue
Block a user