Aar*_*sen 137
PowerShell 3具有$PSScriptRoot 自动变量:
包含运行脚本的目录.
在Windows PowerShell 2.0中,此变量仅在脚本模块(.psm1)中有效.从Windows PowerShell 3.0开始,它在所有脚本中都有效.
不要被糟糕的措辞所迷惑.PSScriptRoot是当前文件的目录.
在PowerShell 2中,您可以计算$PSScriptRoot自己的价值:
# PowerShell v2
$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
123892 次 |
| 最近记录: |