我想从脚本A调用脚本B而不指定完整路径.我试过了
.\scriptb.ps1
Run Code Online (Sandbox Code Playgroud)
但这不起作用.我真的必须指定整个路径吗?
(对不起这个非常基本的问题,但谷歌无法帮助我!)
tos*_*shi 20
我使用powershell变量,它有一个简单的名称来记住它的用途.
$PSScriptRoot\scriptb.ps1
Run Code Online (Sandbox Code Playgroud)
Tom*_*nik 11
可以使用$MyInvocation
如下:
$executingScriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$scriptPath = Join-Path $executingScriptDirectory "scriptb.ps1"
Invoke-Expression ".\$scriptPath"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
27059 次 |
最近记录: |