Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 回波输出是意外的_Powershell_Environment Variables - Fatal编程技术网

Powershell 回波输出是意外的

Powershell 回波输出是意外的,powershell,environment-variables,Powershell,Environment Variables,我试图在PowerShell上使用echo打印路径,但输出为%path% PS C:\> echo %Path% %Path% PS C:\>echo%路径% %路径% 您能告诉我如何执行此操作吗?在PowerShell中,环境变量通过env范围展开: PS C:\> $env:Path %SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\Windows\system32;C:\Windows;... PS C:\>$env:Path %System

我试图在PowerShell上使用echo打印路径,但输出为
%path%

PS C:\> echo %Path%
%Path%
PS C:\>echo%路径%
%路径%

您能告诉我如何执行此操作吗?

在PowerShell中,环境变量通过
env
范围展开:

PS C:\> $env:Path
%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\Windows\system32;C:\Windows;...
PS C:\>$env:Path
%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\Windows\system32;C:\Windows

%xxx%
变量是一个CMD变量。

%Path%是一个命令行变量,PowerShell不支持该变量。您需要使用适当的环境变量:

echo $env:Path
可能重复的