Skip to content

Instantly share code, notes, and snippets.

@ferventcoder
Last active February 11, 2024 03:15
Show Gist options
  • Star 39 You must be signed in to star a gist
  • Fork 21 You must be signed in to fork a gist
  • Save ferventcoder/78fa6b6f4d6e2b12c89680cbc0daec78 to your computer and use it in GitHub Desktop.
Save ferventcoder/78fa6b6f4d6e2b12c89680cbc0daec78 to your computer and use it in GitHub Desktop.
Installing Software as a Non-Administrator Using Chocolatey
:: Pick one of these two files (cmd or ps1)
:: Set directory for installation - Chocolatey does not lock
:: down the directory if not the default
SET INSTALLDIR=c:\ProgramData\chocoportable
setx ChocolateyInstall %INSTALLDIR%
:: All install options - offline, proxy, etc at
:: https://chocolatey.org/install
@powershell -NoProfile -ExecutionPolicy Bypass -Command "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1" && SET PATH="%PATH%;%INSTALLDIR%\bin"
CALL choco install puppet-agent.portable -y
CALL choco install ruby.portable -y
CALL choco install git.commandline -y
:: pick an editor
::CALL choco install visualstudiocode.portable -y :: Not available yet
CALL choco install notepadplusplus.commandline -y
::CALL choco install nano -y
::CALL choco install vim-tux.portable
:: What else can I install without admin rights?
:: https://chocolatey.org/packages?q=id%3Aportable
# Pick one of these two files (cmd or ps1)
# Set directory for installation - Chocolatey does not lock
# down the directory if not the default
$InstallDir='C:\ProgramData\chocoportable'
$env:ChocolateyInstall="$InstallDir"
# If your PowerShell Execution policy is restrictive, you may
# not be able to get around that. Try setting your session to
# Bypass.
Set-ExecutionPolicy Bypass
# All install options - offline, proxy, etc at
# https://chocolatey.org/install
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# PowerShell 3+?
#iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
choco install puppet-agent.portable -y
choco install ruby.portable -y
choco install git.commandline -y
# pick an editor
#choco install visualstudiocode.portable -y # not yet available
choco install notepadplusplus.commandline -y
#choco install nano -y
#choco install vim-tux.portable
# What else can I install without admin rights?
# https://chocolatey.org/packages?q=id%3Aportable
@P4z
Copy link

P4z commented Feb 26, 2019

For a quick non-admin installation I actually prefer this one-liner:
$env:chocolateyUseWindowsCompression='true' ; $env:ChocolateyInstall="$home\choco" ; iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex ; $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") ; choco --version

@pbb72
Copy link

pbb72 commented Jun 24, 2019

This code is confusing. Is it for installing Chocolatey itself, or is it for installing packages? If both, then why? Does one need to re-install Chocolatey on non-admin systems every time one wants to install a package? Or do most users only every run Chocolatey once, to install their favorite packages, and then never touch it again?

Also, the comment line "PowerShell 3+?" is confusing. Is it so common to still use PowerShell 2 (even though v.6 is current) that 3+ is commented out? Is there any advantage of using the 3+ command on modern systems? Why is it commented out?

Note: the official Chocolatey install documentation links to this gist.

@Hlengs-sa
Copy link

$env:chocolateyUseWindowsCompression='true' ; $env:ChocolateyInstall="$home\choco" ; iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex ; $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") ; choco --version

This worked for me.
Thabk you very mcuh @pbb72

@JulioAyala111
Copy link

$env:chocolateyUseWindowsCompression='true' ; $env:ChocolateyInstall="$home\choco" ; iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex ; $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") ; choco --version

Thanks Bro.

@kiquenet
Copy link

@DanTheDood
Copy link

DanTheDood commented Feb 11, 2024

$env:chocolateyUseWindowsCompression='true' ; $env:ChocolateyInstall="$home\choco" ; iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex ; $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") ; choco --version

Finnaly, my brain doesn't have to hurt just to install chocolatey. thanks @P4z!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment