创建路径并在该目录上运行特定命令

时间:2018-08-26 18:31:52

标签: powershell

enter image description here例如。

$ap = Get-location "cd c:\osit\bin\acf"
$ap ./acf -t

但是它不起作用。错误,它不是命令行开关。

因为acf -t仅适用于该目录,所以我需要创建脚本的原因将自动调用该目录并运行该acf -t

请帮助。谢谢。

2 个答案:

答案 0 :(得分:0)

删除Get-Location部分,cd就可以正常工作:

cd c:\osit\bin\acf
.\acf.cmd -t

答案 1 :(得分:0)

尝试一下(注释以#开头;没有“代码”)

# save the current path to variable $path
$path = Get-Location

# change path to executable
Set-Location -Path 'c:\osit\bin\acf'

# execute programme
.\act.cmd -t

# change back to the path we came from
Set-Location -Path $path