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.
User avatar
ALIENQuake
Posts: 66
Joined: Sun Mar 03, 2013 12:45 pm
Has voted: 1 time

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: 613
Joined: Thu Jun 01, 2017 7:20 am
Answers: 6
Been upvoted: 5 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 Ryn
SAPIEN Technologies, Inc.

User avatar
ALIENQuake
Posts: 66
Joined: Sun Mar 03, 2013 12:45 pm
Has voted: 1 time

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: 613
Joined: Thu Jun 01, 2017 7:20 am
Answers: 6
Been upvoted: 5 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 Ryn
SAPIEN Technologies, Inc.

User avatar
ALIENQuake
Posts: 66
Joined: Sun Mar 03, 2013 12:45 pm
Has voted: 1 time

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: 613
Joined: Thu Jun 01, 2017 7:20 am
Answers: 6
Been upvoted: 5 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 Ryn
SAPIEN Technologies, Inc.