From dfa2e3c42773dd041ca8038a1efcc939f2983553 Mon Sep 17 00:00:00 2001 From: Ori Date: Mon, 2 Dec 2024 21:20:13 +0200 Subject: [PATCH 1/4] Adding the script --- uninstall.ps1 | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 uninstall.ps1 diff --git a/uninstall.ps1 b/uninstall.ps1 new file mode 100644 index 0000000..79a2b83 --- /dev/null +++ b/uninstall.ps1 @@ -0,0 +1,58 @@ +# Define variables +$repoZipUrl = "https://github.com/we-dcode/HeadlessMcAfeeNuker/releases/download/v1.0.0/mcafee_killer.zip" +$localZipPath = "C:\Temp\mcafee_killer.zip" +$repoUnzippedPath = "C:\Temp\mcafee_killer.zip" +$cleanupExe = "mccleanup.exe" + +# Function to download a file +function Download-File { + param ( + [string]$Url, + [string]$Destination + ) + Write-Host "Downloading $Url to $Destination..." + Invoke-WebRequest -Uri $Url -OutFile $Destination -ErrorAction Stop +} + +# Function to unzip a file +function Unzip-File { + param ( + [string]$ZipFilePath, + [string]$DestinationPath + ) + Write-Host "Extracting $ZipFilePath to $DestinationPath..." + Expand-Archive -Path $ZipFilePath -DestinationPath $DestinationPath -Force +} + +# Step 1: Check if the zipped repository exists +if (-Not (Test-Path -Path $localZipPath)) { + Write-Host "Zipped repository not found at $localZipPath." + Download-File -Url $repoZipUrl -Destination $localZipPath +} else { + Write-Host "Zipped repository already exists at $localZipPath." +} + +# Step 2 & 3: Check if the repository is unzipped, and unzip if necessary +if (-Not (Test-Path -Path $repoUnzippedPath)) { + Write-Host "Unzipped repository not found at $repoUnzippedPath." + Unzip-File -ZipFilePath $localZipPath -DestinationPath $repoUnzippedPath +} else { + Write-Host "Unzipped repository already exists at $repoUnzippedPath." +} + +# Step 4: Change to the unzipped repository +Set-Location -Path $repoUnzippedPath + +# Step 5: Run the McAfee cleanup tool +$cleanupToolPath = Join-Path -Path $repoUnzippedPath -ChildPath $cleanupExe + +if (Test-Path -Path $cleanupToolPath) { + Write-Host "Running McAfee cleanup tool..." + Start-Process -FilePath $cleanupToolPath -ArgumentList "-p StopServices,MFSY,PEF,MXD,CSP,Sustainability,MOCP,MFP,APPSTATS,Auth,EMProxy,FWDriver,HW,MAS,MAT,MBK,MCPR,McProxy,McSvcHost,VUL,MHN,MNA,MOBK,MPF,MPFPCU,MPS,SHRED,MPSCU,MQC,MQCCU,MSAD,MSHR,MSK,MSKCU,MWL,NMC,RedirSvc,VS,Remediation,MSC,YAP,TrueKey,LAM,PCB,Symlink,SafeConnect,MGS,WMIRemover,RESIDUE -v -s" -NoNewWindow -Wait -Verb RunAs + Write-Host "McAfee cleanup completed successfully." +} else { + Write-Host "Cleanup tool not found at $cleanupToolPath." +} + +# Cleanup +Write-Host "Script execution completed." From a4848a5fa1cdabe156285e4244f94876a86f16cd Mon Sep 17 00:00:00 2001 From: Ori Date: Mon, 2 Dec 2024 22:39:36 +0200 Subject: [PATCH 2/4] Script refinement - path validation & param alignment --- uninstall.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uninstall.ps1 b/uninstall.ps1 index 79a2b83..a458710 100644 --- a/uninstall.ps1 +++ b/uninstall.ps1 @@ -1,8 +1,8 @@ # Define variables $repoZipUrl = "https://github.com/we-dcode/HeadlessMcAfeeNuker/releases/download/v1.0.0/mcafee_killer.zip" -$localZipPath = "C:\Temp\mcafee_killer.zip" -$repoUnzippedPath = "C:\Temp\mcafee_killer.zip" -$cleanupExe = "mccleanup.exe" +$localZipPath = "C:\temp\mcafee_killer.zip" +$repoUnzippedPath = "C:\temp\mcafee_killer\MCPR" +$cleanupExe = "mccleanup.exe" # Fixed cleanup tool path # Function to download a file function Download-File { @@ -48,7 +48,7 @@ $cleanupToolPath = Join-Path -Path $repoUnzippedPath -ChildPath $cleanupExe if (Test-Path -Path $cleanupToolPath) { Write-Host "Running McAfee cleanup tool..." - Start-Process -FilePath $cleanupToolPath -ArgumentList "-p StopServices,MFSY,PEF,MXD,CSP,Sustainability,MOCP,MFP,APPSTATS,Auth,EMProxy,FWDriver,HW,MAS,MAT,MBK,MCPR,McProxy,McSvcHost,VUL,MHN,MNA,MOBK,MPF,MPFPCU,MPS,SHRED,MPSCU,MQC,MQCCU,MSAD,MSHR,MSK,MSKCU,MWL,NMC,RedirSvc,VS,Remediation,MSC,YAP,TrueKey,LAM,PCB,Symlink,SafeConnect,MGS,WMIRemover,RESIDUE -v -s" -NoNewWindow -Wait -Verb RunAs + & $cleanupToolPath -p StopServices,MFSY,PEF,MXD,CSP,Sustainability,MOCP,MFP,APPSTATS,Auth,EMProxy,FWDriver,HW,MAS,MAT,MBK,MCPR,McProxy,McSvcHost,VUL,MHN,MNA,MOBK,MPF,MPFPCU,MPS,SHRED,MPSCU,MQC,MQCCU,MSAD,MSHR,MSK,MSKCU,MWL,NMC,RedirSvc,VS,Remediation,MSC,YAP,TrueKey,LAM,PCB,Symlink,SafeConnect,MGS,WMIRemover,RESIDUE -v -s Write-Host "McAfee cleanup completed successfully." } else { Write-Host "Cleanup tool not found at $cleanupToolPath." From 2c51e89755ff64734f1d17cbe148593e93042f78 Mon Sep 17 00:00:00 2001 From: Ori Date: Mon, 2 Dec 2024 22:43:07 +0200 Subject: [PATCH 3/4] Removal of unnecessary comments --- uninstall.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uninstall.ps1 b/uninstall.ps1 index a458710..157ab13 100644 --- a/uninstall.ps1 +++ b/uninstall.ps1 @@ -2,7 +2,7 @@ $repoZipUrl = "https://github.com/we-dcode/HeadlessMcAfeeNuker/releases/download/v1.0.0/mcafee_killer.zip" $localZipPath = "C:\temp\mcafee_killer.zip" $repoUnzippedPath = "C:\temp\mcafee_killer\MCPR" -$cleanupExe = "mccleanup.exe" # Fixed cleanup tool path +$cleanupExe = "mccleanup.exe" # Function to download a file function Download-File { From 9778b0b2f36b83dcc90949c445bbc97a30309a92 Mon Sep 17 00:00:00 2001 From: Ori Date: Tue, 3 Dec 2024 19:12:00 +0200 Subject: [PATCH 4/4] Changed file name and fixed file paths --- uninstall.ps1 => HeadlessMcAfeeNuker.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename uninstall.ps1 => HeadlessMcAfeeNuker.ps1 (92%) diff --git a/uninstall.ps1 b/HeadlessMcAfeeNuker.ps1 similarity index 92% rename from uninstall.ps1 rename to HeadlessMcAfeeNuker.ps1 index 157ab13..32c1748 100644 --- a/uninstall.ps1 +++ b/HeadlessMcAfeeNuker.ps1 @@ -1,7 +1,7 @@ # Define variables $repoZipUrl = "https://github.com/we-dcode/HeadlessMcAfeeNuker/releases/download/v1.0.0/mcafee_killer.zip" -$localZipPath = "C:\temp\mcafee_killer.zip" -$repoUnzippedPath = "C:\temp\mcafee_killer\MCPR" +$localZipPath = "C:\Windows\Temp\mcafee_killer.zip" +$repoUnzippedPath = "C:\Windows\Temp\mcafee_killer\MCPR" $cleanupExe = "mccleanup.exe" # Function to download a file