Skip to content

Commit 2ef674a

Browse files
committed
Initial release: WinTrash Toolkit v1.0.0
All-in-one PowerShell script that scans 16 types of Windows application leftovers and cleans them interactively (checkbox picker, per-item backup). - 16 scan modules: PATH, env vars, orphan folders, services, startup, scheduled tasks, uninstall ghosts, App Paths, shortcuts, firewall rules, Defender exclusions, tool root CAs, IFEO, Native Messaging, URL protocols, vendor registry keys - Interactive cleanup: severity filter (F), permanent ignore list (I), everything backed up (.reg/.xml/Recycle Bin) before deletion - Restore from backup, scan history diff, safe temp cleanup, monthly schedule - Developer mode: toolchain cache scan, DevRadar + Claudefy install - UI: vi/en/zh/ru, true-color terminal output, HTML/CSV/JSON reports - Compatible with Windows PowerShell 5.1 and PowerShell 7+
0 parents  commit 2ef674a

7 files changed

Lines changed: 2159 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: windows-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Parse check - Windows PowerShell 5.1
15+
shell: powershell
16+
run: |
17+
$errs = $null
18+
[void][System.Management.Automation.Language.Parser]::ParseFile("$PWD\WinTrash.ps1", [ref]$null, [ref]$errs)
19+
if ($errs.Count) { $errs | ForEach-Object { Write-Error ("Line {0}: {1}" -f $_.Extent.StartLineNumber, $_.Message) }; exit 1 }
20+
Write-Host 'PS 5.1 parse: OK'
21+
22+
- name: Parse check - PowerShell 7
23+
shell: pwsh
24+
run: |
25+
$errs = $null
26+
[void][System.Management.Automation.Language.Parser]::ParseFile("$PWD/WinTrash.ps1", [ref]$null, [ref]$errs)
27+
if ($errs.Count) { $errs | ForEach-Object { Write-Error ("Line {0}: {1}" -f $_.Extent.StartLineNumber, $_.Message) }; exit 1 }
28+
Write-Host 'PS 7 parse: OK'
29+
30+
- name: PSScriptAnalyzer
31+
shell: pwsh
32+
run: |
33+
Install-Module PSScriptAnalyzer -Force -Scope CurrentUser
34+
$results = Invoke-ScriptAnalyzer -Path ./WinTrash.ps1 -Severity Error
35+
$results | Format-Table -AutoSize
36+
if ($results.Count -gt 0) { exit 1 }
37+
38+
- name: Pester tests
39+
shell: pwsh
40+
run: |
41+
Install-Module Pester -MinimumVersion 5.0 -Force -Scope CurrentUser
42+
Invoke-Pester -Path ./tests -CI

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Du lieu ca nhan / file sinh ra khi chay - KHONG dua len repo
2+
PathBackups/
3+
CleanupLogs/
4+
StartupBackups/
5+
WinTrashBackups/
6+
DownloadsLogs/
7+
ScanHistory/
8+
legacy/
9+
wintrash-report_*.html
10+
wintrash.ignore.json
11+
*.log

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Changelog
2+
3+
## [1.0.0] - 2026-07-06
4+
5+
Phiên bản đầu tiên — hợp nhất toàn bộ toolkit vào một file `WinTrash.ps1`.
6+
7+
### Tính năng
8+
- **16 module quét tàn dư**: PATH, EnvVars, Folders (AppData/ProgramData mồ côi), Services, Startup, Tasks, Uninstall ghost, App Paths, Shortcuts, Firewall, Defender exclusions, root CA của proxy tool, IFEO, Native Messaging Hosts, URL Protocols, Vendor registry keys.
9+
- **Dọn dẹp tương tác**: danh sách checkbox (↑↓/Space/A/N), lọc theo mức độ (F), ẩn vĩnh viễn vào `wintrash.ignore.json` (I). Không xóa gì cho tới khi xác nhận.
10+
- **Backup mọi thứ trước khi xóa**: export `.reg`, `.xml` task (kèm manifest), PATH gốc, Recycle Bin cho file/thư mục → `WinTrashBackups\`.
11+
- **Khôi phục** (`-Action restore`): import lại .reg, đăng ký lại task, khôi phục PATH từ bản backup chọn.
12+
- **So sánh lịch sử quét**: mỗi lần scan lưu snapshot vào `ScanHistory\`, báo mục mới/mất so với lần trước (giữ 12 bản).
13+
- **Dọn Temp an toàn**: chỉ file cũ hơn 24h trong User Temp / Windows Temp / CrashDumps.
14+
- **Lịch quét hàng tháng**: tạo/xóa Scheduled Task tự chạy `-Action scan`.
15+
- **Developer mode**: quét cache 15+ toolchain, phát hiện cache mồ côi của toolchain đã gỡ; cài DevRadar + Claudefy (spinner).
16+
- **Sắp xếp Downloads**: chỉ file rời ở gốc, chọn nhóm bằng checkbox, undo script.
17+
- **Đa ngôn ngữ UI**: Tiếng Việt / English / 中文 / Русский.
18+
- **Giao diện terminal**: spinner braille, log kiểu npm/cargo, true-color ANSI (không bị theme remap), banner HASOFTWARE.
19+
- Xuất báo cáo HTML/CSV/JSON.
20+
21+
### Kỹ thuật
22+
- Một file duy nhất, tương thích Windows PowerShell 5.1 + PowerShell 7, UTF-8 BOM.
23+
- Quét không cần Administrator; các thao tác dọn cần quyền sẽ báo rõ.
24+
- Heuristic khớp app: bỏ dấu tiếng Việt, đường dẫn từ UninstallString/DisplayIcon, tiến trình đang chạy, LastAccessTime.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 HASOFTWARE (hoanganhdev)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# WinTrash Toolkit
2+
3+
**Một file PowerShell duy nhất** quét 16 loại tàn dư ứng dụng trên Windows và dọn dẹp **có chọn lọc từng mục** — bạn tự tick bằng phím Space, không có chuyện tự động xóa mọi thứ.
4+
5+
> **Triết lý an toàn:** Quét chỉ đọc -> bạn chọn từng mục bằng checkbox -> xác nhận -> mới xóa (luôn backup .reg/.xml/Recycle Bin trước).
6+
7+
## Cài đặt & chạy lần đầu
8+
9+
> **Quan trọng khi tải file từ mạng:** Windows đánh dấu file tải về và chặn chạy script. Mở PowerShell tại thư mục chứa file và gỡ chặn trước:
10+
>
11+
> ```powershell
12+
> Unblock-File .\WinTrash.ps1
13+
> ```
14+
>
15+
> Nếu gặp lỗi *"running scripts is disabled on this system"*, cho phép script đã ký/cục bộ chạy (chỉ cần làm một lần):
16+
>
17+
> ```powershell
18+
> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
19+
> ```
20+
21+
```powershell
22+
.\WinTrash.ps1
23+
```
24+
25+
1. Chọn **ngôn ngữ**: Tiếng Việt / English / 中文 / Русский
26+
2. Chọn **vai trò**:
27+
- **User** — quét & dọn tàn dư, sắp xếp Downloads
28+
- **Developer** — thêm: quét cache toolchain (npm/NuGet/Gradle/pip...), cài [DevRadar](https://github.com/hasoftware/DevRadar)[Claudefy](https://github.com/hasoftware/Claudefy) (có spinner tiến trình)
29+
30+
Chạy tự động không cần menu:
31+
```powershell
32+
.\WinTrash.ps1 -Language vi -Role Developer -Action scan # chỉ quét + báo cáo HTML
33+
.\WinTrash.ps1 -Language vi -Role User -Action clean # quét + chọn + dọn
34+
```
35+
36+
## Dọn dẹp tương tác (điểm nhấn chính)
37+
38+
Sau khi quét, mọi mục có thể dọn hiện thành **danh sách checkbox**:
39+
40+
```
41+
> [x] [Protocols|High] zax:// (0 MB) -> C:\...\ZaX.exe
42+
[ ] [Folders|Medium] Tencent (613 MB) -> C:\ProgramData\Tencent
43+
[x] [Services|High] Fing.Agent -> C:\Program Files\Fing\...
44+
```
45+
46+
| Phím | Chức năng |
47+
|---|---|
48+
| Phím mũi tên / PgUp / PgDn | Di chuyển |
49+
| **Space** | Chọn / bỏ chọn mục |
50+
| A / N | Chọn tất cả / bỏ tất cả |
51+
| **F** | Lọc theo mức độ (All -> High -> Medium -> Info) |
52+
| **I** | Ẩn mục này vĩnh viễn (ghi vào `wintrash.ignore.json` — không báo lại ở các lần quét sau) |
53+
| **Enter** | Xác nhận (hỏi lại y/N lần cuối) |
54+
| Esc | Hủy, không làm gì |
55+
56+
Cột mức độ tô màu: **High** đỏ | **Medium** vàng | **Info** xanh dương.
57+
58+
**Chưa có gì bị xóa cho tới khi bạn Enter + gõ `y`.** Mỗi lần dọn tạo thư mục `WinTrashBackups\<timestamp>\` chứa: export `.reg` của mọi key/value bị xóa, `.xml` của task, PATH gốc, log đầy đủ. Thư mục/file thì vào Recycle Bin.
59+
60+
## 16 loại tàn dư được quét
61+
62+
| Nhóm | Modules |
63+
|---|---|
64+
| Môi trường | PATH chết, biến môi trường chết (JAVA_HOME...) |
65+
| Đĩa | Thư mục mồ côi AppData/LocalLow/ProgramData |
66+
| Tự khởi động | Services, Run-key + Startup folder, Scheduled Tasks |
67+
| Registry | Mục "ma" Add/Remove, App Paths, URL Protocols, Vendor keys |
68+
| Giao diện | Shortcuts chết (Start Menu/Desktop) |
69+
| **Bảo mật** | Defender exclusions mồ côi, root CA của proxy tool (Burp/Fiddler), IFEO debugger hijack, Native Messaging Hosts hỏng |
70+
| Mạng | Firewall rules mồ côi |
71+
72+
Mức độ: **High** = hỏng khách quan (đích không tồn tại) | **Medium** = heuristic, cần bạn xem xét | **Info** = tham khảo. Chứng chỉ (Certs) không bao giờ bị xóa tự động — chỉ báo cáo, xóa tay qua `certmgr.msc`.
73+
74+
## Các tiện ích đi kèm
75+
76+
- **Khôi phục** (`-Action restore` hoặc menu): chọn bản backup trong `WinTrashBackups\` -> tự import lại `.reg`, đăng ký lại scheduled task, khôi phục PATH.
77+
- **So sánh lịch sử**: mỗi lần quét lưu snapshot vào `ScanHistory\` (giữ 12 bản) và báo *"+N mục mới, M mục biến mất so với lần quét trước"* — biến tool thành máy giám sát sức khỏe hệ thống.
78+
- **Dọn Temp an toàn** (`-Action temp`): chỉ xóa file cũ hơn 24 giờ trong User Temp / Windows Temp / CrashDumps, file đang bị khóa tự bỏ qua.
79+
- **Lịch quét hàng tháng** (`-Action schedule`): tạo/xóa Scheduled Task tự chạy quét ngày 1 hằng tháng.
80+
81+
## Sắp xếp Downloads
82+
83+
Chỉ đụng **file rời ở gốc** Downloads (không bao giờ đụng thư mục con), phân nhóm Documents/Images/Videos/Installers..., bạn **chọn nhóm nào muốn áp dụng** bằng checkbox, file không rõ loại để yên, luôn sinh script `Undo-Downloads_*.ps1` để hoàn tác.
84+
85+
## Developer mode
86+
87+
- Phát hiện 15+ toolchain; cache của toolchain **đã gỡ** (Gradle, Cargo... mồ côi) đưa vào danh sách checkbox để dọn; cache của toolchain **đang dùng** chỉ hiện lệnh dọn chính chủ (`npm cache clean --force`, `dotnet nuget locals all --clear`...) — không tự xóa.
88+
- Cài DevRadar / Claudefy qua npm với spinner, tự kiểm tra Node.js >= 18, log cài đặt đầy đủ.
89+
90+
## Yêu cầu & Lưu ý
91+
92+
- Windows PowerShell 5.1 hoặc PowerShell 7+ (file lưu UTF-8 BOM).
93+
- Không cần Administrator để quét; một số mục khi **dọn** (service, HKLM, PATH Machine, Defender) cần chạy admin — mục lỗi sẽ được báo để chạy lại elevated.
94+
- Heuristic không hoàn hảo: nhóm Medium có thể chứa app portable — luôn đọc kỹ trước khi tick.
95+
- Thư mục `legacy\` chứa các script rời phiên bản cũ (đã được hợp nhất vào `WinTrash.ps1`).
96+
97+
## Giấy phép
98+
99+
MIT — dùng, sửa, chia sẻ tự do.

0 commit comments

Comments
 (0)