14 lines
445 B
PowerShell
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 |