-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrendUninstall.ps1
37 lines (35 loc) · 1.48 KB
/
TrendUninstall.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Download the blank thin installer and upload to publicly accessible website or storage
$url = "http://delltechcentre.com/TrendMicroUninstall.zip"
$installerPath = "C:\TrendUninstallTemp"
$file = "TrendMicroUninstall.zip"
$uninstallFile = "Uninstall.bat"
$path = $installerPath + "\" + $File
$scriptUninstallPath = "$installerPath" + "\" + "$uninstallFile"
# Check if Trend micro is already installed on the computer
$installCheck = Join-Path ([System.Environment]::GetFolderPath("ProgramFilesx86")) "Trend Micro\Security Agent\PccNTMon.exe"
# Try downloading and running as long as the PccNTMon.exe isn't in the "Program Files" folder
if(Test-Path $installCheck) {
try {
# Create directory to download the zip file, fail if it can't create it
if (!(Test-Path -PathType Container -Path $installerPath)) {
Try {
New-Item $installerPath -ItemType Directory -ErrorAction Stop
}
Catch {
Throw "Failed to create Temp Directory"
}
}
$down = New-Object System.Net.WebClient
$down.DownloadFile($url,$path)
#Extract the zip contents
$shell = new-object -com shell.application
$zip = $shell.NameSpace("C:\TrendUninstallTemp\TrendMicroUninstall.zip")
foreach($item in $zip.items()){
$shell.Namespace("C:\TrendUninstallTemp\").copyhere($item)
}
& $scriptUninstallPath
}
catch {
Throw "Failed to run script"
}
}