windows Powershell' 不是内部或外部命令,也不是可运行的程序或批处理文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29778121/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Powershell' is not recognized as an internal or external command, operable program or batch file
提问by Rahul Lodha
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 gettingPowershell' is not recognized as an internal or external command, operable program or batch file
我正在尝试运行 powershell -Command 来执行 powershell 文件作为 Visual Studio 2013 中的后期构建事件但我得到了Powershell' is not recognized as an internal or external command, operable program or batch file
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.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.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.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: echo "Move the PhoenixData namespace schema suffixing it"
10>C:\Program Files (x86)\MSBuild.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 ==========
回答by Jon Tirjan
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"
回答by alloha
Remove BOM byte from the beginning of batch file or convert it's encoding to ANSI. BOM treats system to think you use unavailable command.
从批处理文件的开头删除 BOM 字节或将其编码转换为 ANSI。BOM 将系统视为您使用了不可用的命令。