使用相对路径在chrome中打开html文件

时间:2016-09-15 17:10:23

标签: google-chrome powershell

我正在尝试使用PowerShell打开一个带有相对路径的HTML文件,但不知何故它不起作用:

Start-Process "chrome" -Argument ".\_reports\html-results.html"

我需要一个相对路径,因为此脚本可以在任何文件夹中运行,并且必须以chrome格式打开此HTML文件。

1 个答案:

答案 0 :(得分:0)

您必须使用$MyInvocation变量确定脚本路径。然后,您应该使用Join-Path cmdlet组合路径:

$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
Start-Process "chrome" -Argument (Join-Path $scriptPath ".\_reports\html-results.html")