Skip to content

Instantly share code, notes, and snippets.

@mcgarrah
Last active September 11, 2025 19:31
Show Gist options
  • Save mcgarrah/8c1692897a3286e369c6e659e728c709 to your computer and use it in GitHub Desktop.
Save mcgarrah/8c1692897a3286e369c6e659e728c709 to your computer and use it in GitHub Desktop.
Script to automatically install Chocolatey, adjust visual effects, and install a list of packages

Below you can find a script which will install Chocolatey, adjust some visual effects registry entries, and install a list of packages on your system. This was designed for quickly updating a Windows Sandbox but could be useful for a newly installed system. You can read the article that prompted this at Windows Sandbox for Safe Testing.

The script is called InstallChoco.cmd and it uses PowerShell calls to do most of the heavy work.

The script asks for elevation if needed.

@echo off
:: This script automates several setup tasks on a Windows machine.
:: It adjusts visual effects, installs Chocolatey (a package manager),
:: and then uses Chocolatey to install popular software.
:: --- Part 0: Configuration Variables ---
:: Define the list of Chocolatey packages to install.
set "CHOCO_PACKAGES=googlechrome git vscode notepadplusplus"
:: You can easily add or remove packages here by separating them with spaces.
:: --- Part 1: Adjust Visual Effects and Desktop Icons ---
:: This section modifies Windows Registry settings.
:: It aims to set visual effects to a specific value and show "This PC" icon on desktop.
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"New-Item -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects' -Force | Out-Null; " ^
"Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects' -Name 'VisualFXSetting' -Value 2; " ^
"New-Item -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel' -Force | Out-Null; " ^
"Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel' -Name '{20D04FE0-3AEA-1069-A2D8-08002B30309D}' -Value 0"
:: ---
:: --- Part 2: Install Chocolatey Package Manager ---
:: This section downloads and installs Chocolatey, a command-line package manager for Windows.
:: It also adds Chocolatey's binary directory to the system's PATH environment variable
:: for the current command prompt session.
powershell -NoProfile -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
:: The 'powershell -Command "..."' executes the Chocolatey installation script.
:: The '&&' (batch operator) ensures the next command runs ONLY if the PowerShell command succeeds.
:: 'SET "PATH=..."' adds Chocolatey's install directory to the current session's PATH,
:: making 'choco' command available immediately.
:: ---
:: --- Part 3: Install Software using Chocolatey ---
:: This command uses Chocolatey to silently install multiple applications from the defined list.
:: The '-y' flag automatically confirms any prompts during installation.
choco install %CHOCO_PACKAGES% -y
:: Installs the packages listed in the CHOCO_PACKAGES variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment