Current script location in a pff

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
mikebaz
Posts: 3
Last visit: Wed Jan 20, 2016 10:50 am

Current script location in a pff

Post by mikebaz »

How can I get the location of the currently executing script when it's a PFF that's going to be compiled to an EXE? I want to be able to debug, etc. of course.

I have tried going with
PowerShell Code
Double-click the code block to select all.
Split-Path $MyInvocation.MyCommand.Definition
but that doesn't seem to work in the debugger at least. I've tried some variations on that, but just haven't seen any success.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Current script location in a pff

Post by davidc »

Use the "getscriptdirectory" snippet. It contains the Get-ScriptDirectory function that will work with a packaged exe or a normal script file.

Note: If you use a Project, the function is already included in the global.ps1 file.

David
David
SAPIEN Technologies, Inc.
User avatar
mikebaz
Posts: 3
Last visit: Wed Jan 20, 2016 10:50 am

Re: Current script location in a pff

Post by mikebaz »

Excellent, that worked great. Thanks!
This topic is 10 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.