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

Google chrome 使用相对路径在chrome中打开html文件,google-chrome,powershell,Google Chrome,Powershell,我正在尝试使用PowerShell打开一个具有相对路径的HTML文件,但不知何故它无法工作: Start-Process "chrome" -Argument ".\_reports\html-results.html" 我需要相对路径,因为此脚本可以在任何文件夹中运行,并且必须在chrome中打开此HTML文件。您必须使用$MyInvocation变量确定脚本路径。然后,应使用Join-pathcmdlet组合路径: $scriptPath = split-path -parent $MyI

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

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

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

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

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