无法在Windows 10版本1903上安装Chocolatey

问题描述 投票:0回答:1

我最近将Windows 10升级到了1903版,但是在遇到一些问题并联系Microsoft技术支持后,我已经重置了Windows。现在,我尝试重新安装在重置之前安装的所有内容,其中之一是Chocolatey (The package manager for Windows)

我尝试同时运行两个installation command

(for cmd)

@"%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"

(对于PowerShell)

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

但是每次我收到此错误:

Exception calling "Start" with "0" argument(s): "The specified executable is not a valid application for this OS
platform."
At C:\Users\ehsan\Downloads\install.ps1:206 char:3
+   $process.Start() | Out-Null
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : Win32Exception

Exception calling "BeginOutputReadLine" with "0" argument(s): "StandardOut has not been redirected or the process
hasn't started yet."
At C:\Users\ehsan\Downloads\install.ps1:207 char:3
+   $process.BeginOutputReadLine()
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : InvalidOperationException

Exception calling "WaitForExit" with "0" argument(s): "No process is associated with this object."
At C:\Users\ehsan\Downloads\install.ps1:208 char:3
+   $process.WaitForExit()
+   ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : InvalidOperationException

Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install
again. Error: 7-Zip signalled an unknown error (code )
At C:\Users\ehsan\Downloads\install.ps1:220 char:15
+ ...   default { throw "$errorMessage 7-Zip signalled an unknown error (co ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Unable to unzip...n error (code ):String) [], RuntimeException
    + FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompres
   sion = 'true' and call install again. Error: 7-Zip signalled an unknown error (code )

我还尝试下载install.ps1脚本并手动运行(肯定地将执行策略设置为旁路之后),但是结果与上面相同。值得一提的是,我以管理员身份同时运行cmd和PowerShell进行安装。顺便说一句,我还没有尝试离线安装,因为我无法弄清楚说明中说的是什么。

搜索错误并没有帮助我找到解决方法。

installation windows-10 chocolatey
1个回答
0
投票

我也遇到了同样的问题(至少消息是完全相同的)。我在一个更受控制的环境中安装Chocolatey,也就是说,由于某些安全策略原因,不允许执行脚本的某些部分。

错误是在PowerShell的第192行上,它试图下载一个EXE文件:

Download-File 'https://chocolatey.org/7za.exe' "$7zaExe"

这在我的环境中是不允许的,因此,我已经在Windows上安装了Zip,我只复制了,并将所需文件(7az.exe)重命名为install.ps1(Powershell脚本)正在查找的文件夹对于。

就我而言:

C:\Users\%USER%\AppData\Local\Temp\chocolatey\chocInstall\7za.exe

因此,使用此名称在该路径下具有ZIP exe文件,一切正常。

欢呼声

© www.soinside.com 2019 - 2024. All rights reserved.