1
0
Files
Repository/Tools/PS2EXE-GUI/Examples/Get-ScriptPath.ps1
2025-10-31 08:58:36 +01:00

14 lines
445 B
PowerShell

# Example script to retrieve path to script
# When compiled with PS2EXE the variable MyCommand contains no path anymore
if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript")
{ # Powershell script
$ScriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
}
else
{ # PS2EXE compiled script
$ScriptPath = Split-Path -Parent -Path ([Environment]::GetCommandLineArgs()[0])
}
"Directory of executable file: " + $ScriptPath