-
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
Package cleanup script with NSIS installer #14
Conversation
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.
Summary of Changes
Hello @inode64, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the user experience for the WindowsClearCache tool by transitioning from a manual PowerShell-based setup to a user-friendly, automated graphical installer. The change streamlines the deployment and initial configuration, making the tool more accessible and easier to manage for end-users.
Highlights
- New NSIS Installer: Introduces a new NSIS (Nullsoft Scriptable Install System) script to create a graphical installer (
WindowsClearCacheInstaller.exe) for theDriveClean.ps1script. - Automated Setup: The new installer automates the setup process, including copying the PowerShell script, launching Disk Cleanup for initial configuration, and providing an option to create a weekly scheduled task for automated cleanup.
- Documentation Update: The
README.mdhas been updated to reflect the simplified installation and execution workflow using the new NSIS installer, replacing the previous manual PowerShell instructions. - Build Artifact Exclusion: A
.gitignoreentry has been added to exclude the generatedWindowsClearCacheInstaller.exefrom version control.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request is a great step forward, introducing an NSIS installer to simplify the setup process for users. The documentation has also been updated accordingly. My review includes a few suggestions to enhance the robustness and completeness of the installer. Specifically, I've identified an issue with command argument quoting in the NSIS script and noted the absence of an uninstaller, which is a critical feature for installers. Additionally, I've recommended minor improvements to the README to make the instructions more generic and reliable across different system configurations.
| 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' |
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 quoting for the file path in the schtasks command appears to be incorrect. The \\\" will likely result in a literal \\" being passed in the command, which will cause the scheduled task to fail. For schtasks, inner quotes within the /TR argument should be escaped with a single backslash (\").
nsExec::ExecToLog 'schtasks /Create /TN "WindowsClearCache" /TR "powershell.exe -ExecutionPolicy Bypass -File \"$INSTDIR\\DriveClean.ps1\"" /SC WEEKLY /RL HIGHEST /F'
| !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_LANGUAGE "English" | ||
|
|
||
| Section "Install" | ||
| SetOutPath "$INSTDIR" | ||
| 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' | ||
| SkipTask: | ||
| 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 installer script creates files and a scheduled task but lacks an uninstaller. This is problematic as it leaves files and system configuration (the scheduled task) on the user's machine with no easy way to remove them. It's standard practice for installers to provide an uninstallation routine.
You should add an Uninstall section and the necessary logic to register it. An uninstaller should:
- Be written to the installation directory (e.g.,
WriteUninstaller "$INSTDIR\uninstall.exe"). - Be registered in the Windows "Add/Remove Programs" list.
- Contain logic to delete the scheduled task (e.g.,
schtasks /Delete /TN "WindowsClearCache" /F). - Remove the script files and the installation directory.
| 2) Run `WindowsClearCacheInstaller.exe` as an administrator. | ||
| - The installer launches `cleanmgr.exe /sageset:1` so you can configure Disk Cleanup before the first run. | ||
| - You can choose to create a weekly scheduled task that runs the cleanup with highest privileges. | ||
| - The cleaner script is copied to `c:\Program Files\WindowsClearCache`. |
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 Files is 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 $PROGRAMFILES variable.
| - The cleaner script is copied to `c:\Program Files\WindowsClearCache`. | |
| - The cleaner script is copied to `%ProgramFiles%\WindowsClearCache`. |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary
Testing
makensis WindowsClearCache.nsipwsh -NoProfile -Command "Get-Command -Name ./DriveClean.ps1"(fails: command not found)apt-get install -y powershell(fails: Unable to locate package powershell)https://chatgpt.com/codex/tasks/task_e_68bf02627024832e818798e3d28e7b4e