-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.ps1
More file actions
49 lines (41 loc) · 2.18 KB
/
uninstall.ps1
File metadata and controls
49 lines (41 loc) · 2.18 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
# malware-sandbox Uninstall Script
# This script removes the malware-sandbox configuration
$InstallPath = $PSScriptRoot
# Stop any running sandbox processes
Write-Host "Checking for running sandbox processes..." -ForegroundColor Yellow
$sandboxProcesses = Get-Process | Where-Object { $_.ProcessName -like "*sandbox*" -or $_.ProcessName -like "*WDAGUtilityAccount*" }
if ($sandboxProcesses) {
Write-Host "Found running sandbox processes. Please close all sandbox windows first." -ForegroundColor Yellow
exit 1
}
# Helper: remove a link or directory created by the installer (App, Data, Downloads)
function Remove-SandboxLinkOrDir([string]$name) {
$linkPath = Join-Path $InstallPath $name
if (-not (Test-Path $linkPath)) { return }
try {
$it = Get-Item $linkPath -Force
if ($it.Attributes -band [System.IO.FileAttributes]::ReparsePoint) {
# Remove the directory link itself without touching target contents
# Using .NET avoids recursion prompts and does not traverse into target
[System.IO.Directory]::Delete($linkPath, $false)
Write-Host "Unlinked: $linkPath" -ForegroundColor Gray
}
else {
# It's a real directory that wasn't a link. Leave it untouched (unlink-only policy).
Write-Host "Not a link, leaving directory intact: $linkPath" -ForegroundColor Yellow
}
}
catch {
Write-Warning "Failed to remove $linkPath $($_.Exception.Message)"
}
}
# Remove links for App, Data and Downloads (opposite of install Ensure-DirLink)
Write-Host "Unlinking App, Data, Downloads..." -ForegroundColor Yellow
Remove-SandboxLinkOrDir -name "App"
Remove-SandboxLinkOrDir -name "Data"
Remove-SandboxLinkOrDir -name "Downloads"
# Uninstall will not remove the user persistent data or any files. Everything remains intact.
Write-Host "malware-sandbox unlink completed. No files were deleted." -ForegroundColor Green
Write-Host "Note: Windows Sandbox feature remains enabled." -ForegroundColor Yellow
Write-Host "To disable it, run as Administrator:" -ForegroundColor Yellow
Write-Host "Disable-WindowsOptionalFeature -Online -FeatureName 'Containers-DisposableClientVM'" -ForegroundColor White