![](/img/trans.png)
[英]''Command' is not recognized as a internal or external command, operable program or batch file
[英]Powershell' is not recognized as an internal or external command, operable program or batch file
我正在尝试运行 powershell -Command 来执行 powershell 文件作为 Visual Studio 2013 中的后期构建事件但我得到了
'Powershell' 不是内部或外部命令,也不是可运行的程序或批处理文件
输出窗口上的错误和
Powershell -Command exited with code 9009 error
完整的错误信息:
'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 ==========
听起来你缺少一个环境变量。
将此添加到您的Path
环境变量中:
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
或者
将您的脚本更改为:
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -Command "your command"
从批处理文件的开头删除 BOM 字节或将其编码转换为 ANSI。 BOM 将系统视为您使用了不可用的命令。
我的错误只是我忘记以管理员身份运行 Visual Studio/命令提示符。
尝试
' %SYSTEMROOT%\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe tracert google.com
'
可能需要\\\\
而不是\\
。
我知道一个旧线程,但我最近在使用 JetBrains WebStorm CLI(类似于 VS Code)时遇到了这个问题,结果证明如果我以管理员身份使用 Windows 命令提示符,它运行良好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.