Auto-commit: 2025-10-31 08:58:35
This commit is contained in:
14
Tools/PS2EXE-GUI/Examples/Get-ScriptPath.ps1
Normal file
14
Tools/PS2EXE-GUI/Examples/Get-ScriptPath.ps1
Normal file
@@ -0,0 +1,14 @@
|
||||
# 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
|
||||
Reference in New Issue
Block a user