From: Ardis Lu Date: Sun, 15 Sep 2024 06:04:41 +0000 (-0700) Subject: Use OS-agnostic Invoke-Item to trigger file explorer X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=adc2177c52663d31c4506954093ce20f377f3f1b;p=ArdisUtilities Use OS-agnostic Invoke-Item to trigger file explorer --- diff --git a/ArdisUtilities/ArdisUtilities.psm1 b/ArdisUtilities/ArdisUtilities.psm1 index e9b8a73..363979f 100644 --- a/ArdisUtilities/ArdisUtilities.psm1 +++ b/ArdisUtilities/ArdisUtilities.psm1 @@ -839,19 +839,19 @@ function Get-HelpAsMarkdown { function Open-ParentFolder { <# .SYNOPSIS - Opens File Explorer (explorer.exe) in the folder that contains a command. + Opens the native GUI file explorer (e.g., File Explorer on Windows) in the folder that contains a command. .DESCRIPTION Uses Get-Command to determine the path to an executable, then passes the path to Split-Path to get the - parent folder. Finally, opens the parent folder by passing the path as an argument to explorer.exe. + parent folder. Finally, opens the parent folder by passing the path as an argument to Invoke-Item. .PARAMETER Command - The name of the executable to open the File Explorer to. + The name of the executable to open the file explorer to. .EXAMPLE PS> Open-ParentFolder curl - Opens File Explorer to C:\Windows\system32\. + Opens file explorer to the folder containing the curl binary. #> [CmdletBinding()] @@ -865,7 +865,7 @@ function Open-ParentFolder { } process { - explorer.exe ((Get-Command $Command).Source | Split-Path -Parent) + Invoke-Item ((Get-Command $Command).Source | Split-Path -Parent) } }