-
Notifications
You must be signed in to change notification settings - Fork 8
Package cleanup script with NSIS installer #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: Build Installer | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install NSIS | ||
| run: choco install nsis -y | ||
| - name: Build installer | ||
| run: makensis WindowsClearCache.nsi | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: WindowsClearCacheInstaller | ||
| path: WindowsClearCacheInstaller.exe |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| WindowsClearCacheInstaller.exe |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| !include "MUI2.nsh" | ||
|
|
||
| Name "Windows Clear Cache" | ||
| OutFile "WindowsClearCacheInstaller.exe" | ||
| InstallDir "$PROGRAMFILES\\WindowsClearCache" | ||
| RequestExecutionLevel admin | ||
|
|
||
| !insertmacro MUI_PAGE_WELCOME | ||
| !insertmacro MUI_PAGE_DIRECTORY | ||
| !insertmacro MUI_PAGE_INSTFILES | ||
| !insertmacro MUI_UNPAGE_CONFIRM | ||
| !insertmacro MUI_UNPAGE_INSTFILES | ||
| !insertmacro MUI_LANGUAGE "English" | ||
|
|
||
| Section "Install" | ||
| SetOutPath "$INSTDIR" | ||
| WriteUninstaller "$INSTDIR\\Uninstall.exe" | ||
| File "DriveClean.ps1" | ||
|
|
||
| DetailPrint "Open Disk Cleanup configuration" | ||
| nsExec::ExecToLog 'cleanmgr.exe /sageset:1' | ||
|
|
||
| MessageBox MB_YESNO "Create a weekly scheduled cleanup task?" IDNO SkipTask | ||
| nsExec::ExecToLog 'schtasks /Create /TN "WindowsClearCache" /TR "powershell.exe -ExecutionPolicy Bypass -File \\\"$INSTDIR\\DriveClean.ps1\\\"" /SC WEEKLY /RL HIGHEST /F' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The quoting for the file path in the |
||
| SkipTask: | ||
| SectionEnd | ||
|
|
||
| Section "Uninstall" | ||
| nsExec::ExecToLog 'schtasks /Delete /TN "WindowsClearCache" /F' | ||
| Delete "$INSTDIR\\DriveClean.ps1" | ||
| Delete "$INSTDIR\\Uninstall.exe" | ||
| RMDir "$INSTDIR" | ||
| SectionEnd | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path
c:\Program Filesis hardcoded. This path can be different on non-English versions of Windows or on systems where it has been moved. It's better to use the environment variable%ProgramFiles%to be more accurate, especially since the NSIS script correctly uses the$PROGRAMFILESvariable.