简体   繁体   English

“PowerShell”未被识别为内部或外部命令

[英]'PowerShell' is not recognized as an internal or external command

I have just installed Chocolatey via PowerShell, I tried running PowerShell both as myself and as administrator, and if I try running choco or cinst I get the following error: 我刚刚通过PowerShell安装了Chocolatey,我尝试以自己和管理员身份运行PowerShell,如果我尝试运行choco或cinst,我会收到以下错误:

PS C:\> choco /?
'PowerShell' is not recognized as an internal or external command,
operable program or batch file.

What do I do? 我该怎么办? I have a feeling this is related to more than just Chocolatey... 我觉得这不仅仅与Chocolatey有关......

This can happen if a program is not on your PATH. 如果程序不在您的PATH上,则会发生这种情况。 Open a PowerShell prompt and enter 打开PowerShell提示并输入

[environment]::setEnvironmentVariable('PATH',
"$env:path;C:\Windows\System32\WindowsPowerShell\v1.0", 'm')

then restart PowerShell. 然后重新启动PowerShell。

I found this helpful. 我觉得这很有帮助。

  • Write cmd in the start menu, right-click and run as administrator. 在开始菜单中编写cmd,右键单击并以管理员身份运行。
  • Then in the cmd, paste in this to install choco 然后在cmd中,粘贴在此安装choco

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString(' https://chocolatey.org/install.ps1 '))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin @powershell -NoProfile -ExecutionPolicy Bypass -Command“iex((new-object net.webclient).DownloadString(' https://chocolatey.org/install.ps1 '))”&& SET PATH =%PATH%;%ALLUSERSPROFILE% \\的巧克力\\斌

Put Chocolatey on the path. 把Chocolatey放在路上。

Edit the system environmental variable. 编辑系统环境变量。 Go to

System PropertiesAdvancedEnvironment VariablesSystem variablesPATHEditNew 系统属性高级环境变量系统变量路径编辑新建

Look for where Chocolatey is. 寻找Chocolatey的位置。 In my case it was at C:\\ProgramData\\chocolatey . 就我而言,它位于C:\\ProgramData\\chocolatey Enter that, don't forget to put "\\" after Chocolatey. 输入,不要忘记在Chocolatey之后加上“\\”。 Ie, it should be: C:\\ProgramData\\chocolatey\\ 即,它应该是: C:\\ProgramData\\chocolatey\\

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在docker中运行powershell时,获取select不会被识别为内部或外部命令 - getting a select is not recognized as an internal or external command when running powershell in docker 无法安装Windows 7的NativeScript“无法将Powershell识别为内部或外部命令” - Can't install NativeScript for Windows 7 “Powershell is not recognized as an internal or external command” Powershell' 不是内部或外部命令,也不是可运行的程序或批处理文件 - Powershell' is not recognized as an internal or external command, operable program or batch file 使用 Powershell 运行 a.bat 脚本时避免“不被识别为内部或外部命令” - Avoiding “is not recognized as an internal or external command” when running a .bat script with Powershell $ Branch不被识别为内部或外部命令 - $Branch is not recognized as an internal or external command 'es' 不被识别为内部或外部命令 - 'es' is not recognized as an internal or external command PowerShell在命令提示符问题中,“格式表”未被识别为内部或外部命令,可操作程序或批处理文件 - PowerShell in command prompt issue, 'Format-Table' is not recognized as an internal or external command, operable program or batch file powershell 上的 Azure CLI 命令给出“c:\\\”Program' 不被识别为内部或外部命令, - Azure CLI command on powershell is giving '“c:\\\”Program' is not recognized as an internal or external command, 创建 cordova 应用程序错误是 powershell 未被识别为内部或外部命令、可运行程序或批处理文件 - While creating a cordova app error is powershell is not recognized as an internal or external command, operable program or batch file pipenv shell 在虚拟环境中启动子shell…“powershell.exe”不是内部或外部命令,也不是可运行的程序或 - pipenv shell Launching subshell in virtual environment… 'powershell.exe' is not recognized as an internal or external command, operable program or
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM