How to get PS7 Form executable path/name?

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 3 years and 5 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
ALIENQuake
Posts: 112
Last visit: Mon Jan 29, 2024 7:35 am
Has voted: 4 times

How to get PS7 Form executable path/name?

Post by ALIENQuake »

Hi,


How to get PS7 Form executable path/name?

Things which I try and receive 'SAPIEN.PoshCoreHostWin':

Code: Select all

System.AppDomain.CurrentDomain.FriendlyName
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
Environment.GetCommandLineArgs()[0]
I want MyApp.exe or full path.

Product, version and build:
Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.182
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.19042.0
PowerShell version(s): 7.0.3
by brittneyr » Tue Oct 27, 2020 7:49 am
We are paying attention to the issue on GitHub. If Microsoft does not add it in a reasonable amount of time, we will then consider other options, but at this time, we have no plans for a workaround.
Go to full post
User avatar
brittneyr
Site Admin
Posts: 1671
Last visit: Tue Apr 16, 2024 8:12 am
Answers: 39
Been upvoted: 31 times

Re: How to get PS7 Form executable path/name?

Post by brittneyr »

I'm not sure what you have tried, but please try the following function to get the path to your executable:

Code: Select all

function get-scriptdirectory{
  if($hostinvocation -ne $null) {
    Split-Path $hostinvocation.MyCommand.path
  }
  else {
    $invocation=(get-variable MyInvocation -Scope 1).Value
    Split-Path $invocation.myinvocation.path
  }
}
Brittney
SAPIEN Technologies, Inc.
User avatar
ALIENQuake
Posts: 112
Last visit: Mon Jan 29, 2024 7:35 am
Has voted: 4 times

Re: How to get PS7 Form executable path/name?

Post by ALIENQuake »

Hi, thanks for reply, I'm aware about this function but I don't want an executable directory, I want an executable fullpath or name.
User avatar
brittneyr
Site Admin
Posts: 1671
Last visit: Tue Apr 16, 2024 8:12 am
Answers: 39
Been upvoted: 31 times

Re: How to get PS7 Form executable path/name?

Post by brittneyr »

Ah, I see the issue. There is no way to accomplish this at the moment, my apologies for the misunderstanding on my part.
The issue is a result of how executables are made in .Net Core. In .Net Core, executable only functions as launcher for the actual application, in this case SAPIEN.CoreWinAppHost.dll.

There is an issue that was made relatively recently on GitHub regarding the issue:
https://github.com/dotnet/runtime/issues/40862

As for when the resolution is released for us to then add to our products, there is no timeline at this time.
Brittney
SAPIEN Technologies, Inc.
User avatar
ALIENQuake
Posts: 112
Last visit: Mon Jan 29, 2024 7:35 am
Has voted: 4 times

Re: How to get PS7 Form executable path/name?

Post by ALIENQuake »

I suspected that it might be NET-related.

May I ask for a workaround?
Instead of using SAPIEN.CoreWinAppHost as the basename for .dll, can you use 'project name' instead? So we can later use MyApp.dll as a reference?
User avatar
brittneyr
Site Admin
Posts: 1671
Last visit: Tue Apr 16, 2024 8:12 am
Answers: 39
Been upvoted: 31 times

Re: How to get PS7 Form executable path/name?

Post by brittneyr »

We are paying attention to the issue on GitHub. If Microsoft does not add it in a reasonable amount of time, we will then consider other options, but at this time, we have no plans for a workaround.
Brittney
SAPIEN Technologies, Inc.
This topic is 3 years and 5 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.