'choco' command not recognized when run as administrator on Windows
Solution 1
- First, ensure that you are using an administrative shell of command prompt(https://www.howtogeek.com/194041/how-to-open-the-command-prompt-as-administrator-in-windows-8.1/).
-
Copy the below text into the command prompt.
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Then press enter key from the keyboard. After few seconds you get complete info about current installation.
If you don't see any errors. Type
choco
orchoco -?
now.
Solution 2
First Open the Command prompt as administrator and then run -
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
And then restart the Command prompt, now choco is successfully installed
Solution 3
The choco
environment variable
has been altered. I ran into a similar problem when I tried setting env variable
for Java SDK
, but I was quick to recognize it when I ran the commands
presented to me in the documentation which completely overwrites my env Path variable
.
If you are sure you've choco installed. Check your System variables
and look for Path variable
if it has some values like C:\ProgramData\chocolatey\choco.exe;C:\ProgramData\chocolatey\bin
if not add
it.
And you can save you time by installing it. Installing via cmd line
Powershell:
Copy and Paste the code below to your PowerShell
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
OR Window CMD.exe:
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
After installation: run choco
you see the version of chocolatey installed. Mine
Chocolatey v0.10.14
Please run 'choco -?' or 'choco <command> -?' for help menu.
hopefully this help read more
Solution 4
You can follow the below mentioned steps to install Chocolatey:
- Start Powershell as Admin.
- Excecute the command:
Get-ExecutionPolicy
. The output should show:Restricted
. - If the output is Restricted, then execute the command:
Set-ExecutionPolicy AllSigned
. - Then execute this command to install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
. - You can verify the installation by executing the command:
choco
.
Solution 5
Open command prompt in administrator mode and run this command:
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command " [System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
![Nicholas Kajoh](https://i.stack.imgur.com/0Z0SS.jpg?s=256&g=1)
Nicholas Kajoh
Updated on September 04, 2021Comments
-
Nicholas Kajoh almost 3 years
I installed Chocolatey as per the instructions on the website (https://chocolatey.org/install).
The 'choco' command works fine when I run it normally on cmd but returns the following error when run as administrator:
C:\WINDOWS\system32>choco install -y wget 7zip.commandline 'choco' is not recognized as an internal or external command, operable program or batch file.
The install
choco install -y wget 7zip.commandline
fails if not run as administrator.How do I fix 'not recognized' error in admin cmd?
-
rahulserver about 6 yearsThis should be another question or comment @Moderator
-
alelom over 5 yearsDoes not work for me. How does this differ from the normal choco installation?
-
alelom over 5 yearsUnfortunately also this does not work for me, although
SET PATH
could be the way to go -
Asell almost 4 yearsThank youuuu duuude
-
Grant Curell almost 4 yearsNot sure why this got downvoted, but I also found that you had to use cmd. Powershell didn't work for me, but running the same thing in cmd it worked immediately.
-
Ashok over 3 yearsI suggest reading: stackoverflow.com/help/how-to-answer
-
Sid over 2 yearsYou can also run
refreshenv
instead of rebooting. -
user3437460 almost 2 yearsI got
Access Denied
. Anyways to overcome that? Have already run cmd as Administrator.