修复Chocolatey“访问被拒绝”

时间:2019-04-09 19:46:47

标签: chocolatey

我是在admin cmd中使用this命令首次安装Chocolatey的:

  

@“%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”

管理员cmd输出:

Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.13.
Extracting C:\Users\CurrentUser\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\CurrentUser\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
  Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
  before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
  (i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
  and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.

Creating Chocolatey folders if they do not already exist.

WARNING: You can safely ignore errors related to missing log files when
  upgrading from a version of Chocolatey less than 0.9.9.
  'Batch file could not be found' is also safe to ignore.
  'The system cannot find the file specified' - also safe.
WARNING: Not setting tab completion: Profile file does not exist at
'C:\Users\CurrentUser\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
WARNING: Unable to run Chocolately at this time.  It is likely that .Net Framework installation requires a system reboot
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
 first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder

重新启动cmd之后,我仍然无法访问choco命令:

enter image description here

他们似乎没有记录为什么会发生这种情况。我该如何解决?

2 个答案:

答案 0 :(得分:6)

以管理员身份运行命令提示符,然后运行命令“ choco install nodejs”

答案 1 :(得分:2)

这可能与防病毒有关,在我的情况下是Sophos,需要将choco添加为白名单