My personalized dotfiles and configs for Windows 10 ⚙️
Chocolatey is the best all-around, all-purpose package manager for Windows. It is build off PowerShell and NuGet and has a vast community full or resources and submitted packages for software installations.
This directory houses backup files provided from the choco-package-list-backup
tool. In particular it contains the latest packages.config
file, the choco-package-list-backup.config
configuration used to generate it, and a gitignored InstChoco.exe
executable.
These tools are located under C:\tools\BCURRAN3
.
Additionally, I provide a custom batch file: post-cplb-git-push.bat
to automatically push changes in the backups directory to Git/GitHub.
post-cplb-git-push.bat
batch fileChocolatey’s core configuration file located at C:ProgramData\chocolatey\config
. (XML Formatted .config
file).
Setup scripts are split into three parts:
The install-choco.ps1 script performs the following steps:
$PROFILE
if does not exist (allows chocolatey to incorporate its profile and tab-autocompletion on install)$PROFILE
#Requires -RunAsAdministrator
# -------------------------------
# Chocolatey Installation Script
# -------------------------------
# Check Administrative Priveledges
$isadmin = (new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole("Administrators")
if (-not ($isadmin)) { throw "Must have Admininstrative Priveledges..." }
# Check/Set Execution Policy
$exepolicy = Get-ExecutionPolicy
if ($exepolicy -ne 'Unrestricted') {
Write-Host "Setting Execution Policy to Unrestricted" -ForegroundColor Blue
Set-ExecutionPolicy Unrestricted
Set-ExecutionPolicy Unrestricted -scope CurrentUser
}
# Create $PROFILE if necessary before installing:
if (!(Test-Path -Path $PROFILE)) {
Write-Host "Creating Powershell Profile" -ForegroundColor Blue
New-Item -ItemType File -Path $PROFILE -Force
}
# Install
try { Get-Command -Name choco -ErrorAction Stop }
catch [System.Management.Automation.CommandNotFoundException] {
Write-Host "Installing Chocolatey..." -ForegroundColor Yellow
Set-ExecutionPolicy Bypass -Scope Process -Force;
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
. $PROFILE
refreshenv
}
Write-Host "Finished Installing Chocolatey. Run Configuration script now." -ForegroundColor Green
The configuration script setups up various features, settings, and system properties to make chocolatey ready for use.
The config-choco.ps1 script performs the following steps:
%PATH%
(see helper function Add-PathVariable
)$env:chocolateyinstall
(i.e. C:\ProgramData\chocolatey
)allowGlobalConfirmation
cacheLocation
to $env:TEMPlogEnvironmentValues
virusCheck
virusScannerType
to VirusTotal
useRememberedArgumentsForUpgrades
removePackageInformationOnUninstall
git
to system with custom silent install parameters that add UNIX tools to PATH, add Git Bash Windows Terminal Profile, Configure AutoUpdate, etc.$PROFILE
and Refreshes environment#Requires -RunAsAdministrator
# -------------------------------
# Helper Functions
# -------------------------------
Function Add-PathVariable {
param (
[string]$addPath
)
if (Test-Path $addPath){
$regexAddPath = [regex]::Escape($addPath)
$arrPath = $env:Path -split ';' | Where-Object {$_ -notMatch "^$regexAddPath\\?"}
$env:Path = ($arrPath + $addPath) -join ';'
} else {
Throw "'$addPath' is not a valid path."
}
}
# --------------------------------
# Chocolatey Configuration Script
# --------------------------------
# Check Administrative Priveledges
$isadmin = (new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole("Administrators")
if (-not ($isadmin)) { throw "Must have Admininstrative Priveledges..." }
Write-Host "Configuring Chocolatey" -ForegroundColor Blue
# Enable Long Path Support:
Write-Host "Enabling Long Path Support through Registry..." -ForegroundColor Yellow
Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1
# Add to PATH:
Write-Host "Ensuring Chocolatey on System %PATH%..." -ForegroundColor Yellow
Add-PathVariable "$env:ALLUSERSPROFILE\chocolatey\bin"
# Add Defender Exclusion:
Write-Host "Adding Chocolatey to Defender Exclusion List..." -ForegroundColor Yellow
App-MpPreference -ExclusionPath $env:chocolateyinstall
# Configure Features and Settings:
Write-Host "Configuring Chocolatey's Settings and Features..." -ForegroundColor Yellow
choco feature enable -n allowGlobalConfirmation
choco config set cacheLocation $env:TEMP
choco feature enable -n logEnvironmentValues
choco feature enable -n virusCheck
choco config set virusScannerType VirusTotal
choco feature enable -n useRememberedArgumentsForUpgrades
choco feature enable -n removePackageInformationOnUninstall
Write-Host "Done. Current feature set is: " -ForegroundColor Green
choco feature list
# Initial Installations:
Write-Host "Installing chocolatey helpers.." -ForegroundColor Yellow
choco upgrade boxstarter choco-cleaner choco-package-list-backup instchoco chocolateygui 7zip -y
refreshenv
# Install Git w/ Custom Parameters
Write-Host "Installing Git with Custom Parameters..." -ForegroundColor Yellow
choco upgrade git.install --params "/GitAndUnixToolsOnPath /WindowsTerminal /NoShellIntegration /NoAutoCrlf" --install-arguments='/COMPONENTS="icons,assoc,assoc_sh,autoupdate,windowsterminal,scalar"'
refreshenv
# Finish:
refreshenv
. $profile
refreshenv
Write-Host "Finished Configuring Chocolatey." -ForegroundColor Green
The bootstrap-choco.ps1
script re-installs all chocolatey packages for a system.
See packages.config.
$compinfo = Get-ComputerInfo
$compname = $compinfo.CsDNSHostName
if ($compname -eq "DESKTOP-MSI") { choco install -y "$HOME\.dotfiles\chocolatey\backup\MSI\packages.config" }
if ($compname -eq "DESKTOP-LENOVO") { choco install -y "$HOME\.dotfiles\chocolatey\backup\Lenovo\packages.config" }
Note the following installations utilize custom parameters during install:
autocrlf
configurationC:\Python39
or C:\Program Files\Python39
CLOUSDK_PYTHON
Environment Variable# GIT.INSTALL
choco install -y git.install `
--install-arguments='"/COMPONENTS=icons,assoc,assoc_sh,autoupdate,windowsterminal,scalar"' `
--package-parameters='"/GitAndUnixToolsOnPath /WindowsTerminal /NoShellIntegration /NoAutoCrlf"'
# PYTHON3
choco install python3 --install-arguments="'/quiet InstallAllUsers=1 PrependPath=1'"
# R
choco install R.Project --params "'/AddToPath'"
# GCLOUD
cinst gcloudsdk --not-silent