Skip to content

Commit c4745fd

Browse files
authored
Merge pull request #14 from inode64/codex/create-installer-with-scheduled-task-options
Package cleanup script with NSIS installer
2 parents 0fb332c + fe78daf commit c4745fd

4 files changed

Lines changed: 72 additions & 12 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build Installer
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Install NSIS
15+
run: choco install nsis -y
16+
- name: Build installer
17+
run: makensis WindowsClearCache.nsi
18+
- name: Upload artifact
19+
uses: actions/upload-artifact@v4
20+
with:
21+
name: WindowsClearCacheInstaller
22+
path: WindowsClearCacheInstaller.exe

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WindowsClearCacheInstaller.exe

README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
# WindowsClearCache
22

3-
Simple scripts to clear temp files, browser cache/history, caches for applications like Microsoft Teams, Slack, Discord, Opera, and OneDrive, and remove Windows Defender scan and definition update backups (including the NisBackup folder), Windows dump files, and Windows Error Reporting (WER) temp files
3+
Simple scripts to clear temp files, browser cache/history, caches for applications like Microsoft Teams, Slack, Discord, Opera,
4+
and OneDrive, and remove Windows Defender scan and definition update backups (including the NisBackup folder), Windows dump files, and Windows Error Reporting (WER) temp files
45

5-
## How To Run
6+
## Installation
7+
8+
1) Build the graphical installer by running `makensis WindowsClearCache.nsi` (or download a pre-built `WindowsClearCacheInstaller.exe`).
9+
2) Run `WindowsClearCacheInstaller.exe` as an administrator.
10+
- The installer launches `cleanmgr.exe /sageset:1` so you can configure Disk Cleanup before the first run.
11+
- You can choose to create a weekly scheduled task that runs the cleanup with highest privileges.
12+
- The cleaner script is copied to `c:\Program Files\WindowsClearCache`.
613

7-
To run this with parameters, do the following:
14+
## How To Run
815

9-
1) Download the .zip file on the main page of the GitHub and extract the .zip file to your desired location, e.g. - `c:\WindowsClearCache`
10-
2) Once extracted, open [PowerShell](https://docs.microsoft.com/en-us/powershell/scripting) (or [PowerShell ISE](https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/ise/introducing-the-windows-powershell-ise)) as an Administrator
11-
3) Enable PowerShell execution: `Set-ExecutionPolicy Unrestricted -Force` (to allow executing unsigned code)
12-
4) Run the Disk Cleanup utility (cleanmgr.exe) with the /sageset:1 option, which allows users to configure cleanup settings before executing the actual cleanup process
13-
e.g. - `cleanmgr.exe /sageset:1`
14-
5) On the prompt, change to the directory where you extracted the files:
15-
e.g. - `cd c:\Program Files\WindowsClearCache`
16-
6) Next, to run the script, enter in the following:
17-
e.g. - `.\DriveClean.ps1`
16+
After installation you can run the cleaner manually with:
17+
`powershell.exe -ExecutionPolicy Bypass -File "%ProgramFiles%\WindowsClearCache\DriveClean.ps1"`
1818

1919
Optional flags:
2020

2121
- Use `-DryRun` to preview the files that would be deleted without removing them.
2222
- Use `-Verbose` to display each file as it is deleted (or would be deleted in dry run).
2323

24+
## Uninstallation
25+
26+
Run `Uninstall.exe` from `c:\Program Files\WindowsClearCache` or use Add/Remove Programs. This removes the scheduled task and deletes the installed files.
27+
2428
## Tested on following Windows Versions
2529

2630
Verified on the following platforms:

WindowsClearCache.nsi

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
!include "MUI2.nsh"
2+
3+
Name "Windows Clear Cache"
4+
OutFile "WindowsClearCacheInstaller.exe"
5+
InstallDir "$PROGRAMFILES\\WindowsClearCache"
6+
RequestExecutionLevel admin
7+
8+
!insertmacro MUI_PAGE_WELCOME
9+
!insertmacro MUI_PAGE_DIRECTORY
10+
!insertmacro MUI_PAGE_INSTFILES
11+
!insertmacro MUI_UNPAGE_CONFIRM
12+
!insertmacro MUI_UNPAGE_INSTFILES
13+
!insertmacro MUI_LANGUAGE "English"
14+
15+
Section "Install"
16+
SetOutPath "$INSTDIR"
17+
WriteUninstaller "$INSTDIR\\Uninstall.exe"
18+
File "DriveClean.ps1"
19+
20+
DetailPrint "Open Disk Cleanup configuration"
21+
nsExec::ExecToLog 'cleanmgr.exe /sageset:1'
22+
23+
MessageBox MB_YESNO "Create a weekly scheduled cleanup task?" IDNO SkipTask
24+
nsExec::ExecToLog 'schtasks /Create /TN "WindowsClearCache" /TR "powershell.exe -ExecutionPolicy Bypass -File \\\"$INSTDIR\\DriveClean.ps1\\\"" /SC WEEKLY /RL HIGHEST /F'
25+
SkipTask:
26+
SectionEnd
27+
28+
Section "Uninstall"
29+
nsExec::ExecToLog 'schtasks /Delete /TN "WindowsClearCache" /F'
30+
Delete "$INSTDIR\\DriveClean.ps1"
31+
Delete "$INSTDIR\\Uninstall.exe"
32+
RMDir "$INSTDIR"
33+
SectionEnd

0 commit comments

Comments
 (0)