'choco' command not recognized when run as administrator on Windows

Nicholas Kajoh picture Nicholas Kajoh · Dec 18, 2017 · Viewed 52.1k times · Source

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?

Answer

Krishnarjun Banoth picture Krishnarjun Banoth · Apr 19, 2018
  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/).
  2. 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"
    
  3. Then press enter key from the keyboard. After few seconds you get complete info about current installation.

  4. If you don't see any errors. Type choco or choco -? now.

Reference