[英]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"
or Right click start button -> System -> Advanced system settings -> Environment Variables... -> Select PATH或右键单击开始按钮 -> 系统 -> 高级系统设置 -> 环境变量... -> 选择 PATH
C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\
or %SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\
或%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\
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.