Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 314
Nicholas Kajoh Avatar asked Dec 18 '17 02:12

Nicholas Kajoh


People also ask

How do you check Choco is installed or not?

Verify Installation To verify that Chocolatey is installed, we will use the choco command. C:\WINDOWS\system32>choco Chocolatey v0. 10.15 Please run 'choco -? ' or 'choco -?

How do I install chocolatey on Windows 10?

Install via Command LinePress the Windows key and type "cmd". Select the Run as administrator option. Wait for the installation process to finish to start using Chocolatey. Note: Make sure to close and reopen the shell before using Chocolatey to ensure all the environment variables are loaded correctly.


1 Answers

  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

like image 196
Krishnarjun Banoth Avatar answered Sep 20 '22 13:09

Krishnarjun Banoth