简体   繁体   English

Powershell' 不是内部或外部命令,也不是可运行的程序或批处理文件

[英]Powershell' is not recognized as an internal or external command, operable program or batch file

I am trying to run a powershell -Command to execute a powershell file as a post build event in Visual studio 2013 But i am getting我正在尝试运行 powershell -Command 来执行 powershell 文件作为 Visual Studio 2013 中的后期构建事件但我得到了

'Powershell' is not recognized as an internal or external command, operable program or batch file 'Powershell' 不是内部或外部命令,也不是可运行的程序或批处理文件

error on output window and输出窗口上的错误和

Powershell -Command exited with code 9009 error

Full Error Message:完整的错误信息:

'Powershell' is not recognized as an internal or external command,
10>  operable program or batch file.
10>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: The command "echo "C:\dev\tfs\Main\Shared\AggregationComponents\GenerateSchema.cmd"
10>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: call "C:\dev\tfs\Main\Shared\AggregationComponents\GenerateSchema.cmd"
10>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: echo "Move the PhoenixData namespace schema suffixing it"
10>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: Powershell -Command "C:\dev\tfs\Main\Shared\AggregationComponents\MoveAndRenameXsds.ps1 'C:\dev\tfs\Main\Shared\AggregationComponents\bin\Debug\' 'C:\dev\tfs\Main\Shared\AggregationComponents\..\PublishedAnalyticsXsds' '.Aggregation'"" exited with code 9009.
========== Rebuild All: 8 succeeded, 1 failed, 1 skipped ==========

Sounds like you're missing an environment variable.听起来你缺少一个环境变量。

Add this to your Path environment variable:将此添加到您的Path环境变量中:

%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

OR或者

Change your script to this:将您的脚本更改为:

%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -Command "your command"

You only need to add it to your environment variables , just follow the following two simple steps:您只需要将其添加到您的环境变量中,只需遵循以下两个简单步骤:

1.write env in the search bar 1.在搜索栏中写入env

or Right click start button -> System -> Advanced system settings -> Environment Variables... -> Select PATH右键单击开始按钮 -> 系统 -> 高级系统设置 -> 环境变量... -> 选择 PATH

2. click on the new button and add the following path: 2.点击新建按钮,添加如下路径:

C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\

or %SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\


在搜索栏中写入 env 选择路径 单击确定

Remove BOM byte from the beginning of batch file or convert it's encoding to ANSI.从批处理文件的开头删除 BOM 字节或将其编码转换为 ANSI。 BOM treats system to think you use unavailable command. BOM 将系统视为您使用了不可用的命令。

我的错误只是我忘记以管理员身份运行 Visual Studio/命令提示符。

try尝试

' %SYSTEMROOT%\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe tracert google.com ' ' %SYSTEMROOT%\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe tracert google.com '

might require \\\\ instead of \\ .可能需要\\\\而不是\\

我知道一个旧线程,但我最近在使用 JetBrains WebStorm CLI(类似于 VS Code)时遇到了这个问题,结果证明如果我以管理员身份使用 Windows 命令提示符,它运行良好。

暂无
暂无

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

相关问题 “命令”不是内部或外部命令,也不是可运行的程序或批处理文件 - ''Command' is not recognized as a internal or external command, operable program or batch file PowerShell在命令提示符问题中,“格式表”未被识别为内部或外部命令,可操作程序或批处理文件 - PowerShell in command prompt issue, 'Format-Table' is not recognized as an internal or external command, operable program or batch file 无法将“ slc”识别为内部或外部命令,可操作程序或批处理文件 - 'slc' is not recognized as an internal or external command, operable program or batch file 'pip3' 不是内部或外部命令,也不是可运行的程序或批处理文件 - 'pip3' is not recognized as an internal or external command, operable program or batch file 无法将“ svn”识别为内部或外部命令,可操作程序或批处理文件 - 'svn' is not recognized as an internal or external command, operable program or batch file 不是内部或外部命令、可运行的程序或批处理文件 - is not recognized as an internal or external command, operable program or batch file 'C:\\wmic' 不是内部或外部命令,也不是可运行的程序或批处理文件 - 'C:\wmic' is not recognized as an internal or external command, operable program or batch file 'fc'不被识别为内部或外部命令,可操作程序或批处理文件 - 'fc' is not recognized as an internal or external command, operable program or batch file Windows碎片整理无法识别为内部或外部命令,可操作程序或批处理文件 - Windows defrag is not recognized as an internal or external command, operable program or batch file Windows 7 - 'make' 不是内部或外部命令,也不是可运行的程序或批处理文件 - Windows 7 - 'make' is not recognized as an internal or external command, operable program or batch file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM