Find full path of a powershell script launched from an EXE wrapper
<p>I am trying to create an .exe file that is a packaged powershell script (script.ps1) in which part of the script is to print the current location of the <strong>.exe file</strong> NOT the Script.</p>

<p>Part of the Requirement is that the .exe needs to be portable:</p>

<p>So when I run File.exe or Double-click File.exe:</p>

<p>If the location of the file is <strong>C:\Hello\File.exe</strong> , it should print <strong>"C:\Hello\"</strong></p>

<p>If the location is moved to <strong>D:\Goodbye\File.exe</strong> , it should print <strong>"D:\Goodbye\"</strong></p>

<p>If the the file is COPIED to <strong>D:\HELLO\File.exe</strong> , it should ONLY print <strong>"D:\HELLO\"</strong></p>

<hr>

<p>I have tried <code>$PSScriptRoot</code> but that only links to a temp folder</p>

<hr>

<p>What code can I add to the script.ps1 before packaging it as an .exe to make it look for the specific location of the <strong>.exe</strong> file?</p>

<p>Thanks</p>