-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_folders.bat
More file actions
32 lines (28 loc) · 982 Bytes
/
delete_folders.bat
File metadata and controls
32 lines (28 loc) · 982 Bytes
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
@echo off
setlocal
set "BASE_DIR=%~dp0"
set "PS_EXE=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"
if not exist "%PS_EXE%" (
echo [ERROR] PowerShell was not found.
pause
exit /b 1
)
"%PS_EXE%" -NoProfile -ExecutionPolicy Bypass -Command ^
"$base = [System.IO.Path]::GetFullPath('%BASE_DIR%');" ^
"$names = @(([string][char]0x8A18 + [char]0x4E8B), ([string][char]0x5143 + [char]0x30CD + [char]0x30BF));" ^
"foreach ($name in $names) {" ^
" $target = Join-Path -Path $base -ChildPath $name;" ^
" if (Test-Path -LiteralPath $target -PathType Container) {" ^
" Remove-Item -LiteralPath $target -Recurse -Force;" ^
" if (Test-Path -LiteralPath $target) { Write-Host ('[FAILED] ' + $name); } else { Write-Host ('[DELETED] ' + $name); }" ^
" } else {" ^
" Write-Host ('[SKIP] ' + $name);" ^
" }" ^
"}"
if errorlevel 1 (
echo [ERROR] Deletion script failed.
) else (
echo [OK] Completed.
)
pause
exit /b %errorlevel%