Get the full path of the EXE

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

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 7 years and 2 weeks 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.
Locked
User avatar
njcappa
Posts: 66
Last visit: Tue Jan 26, 2021 6:59 am

Get the full path of the EXE

Post by njcappa »

PSS 2017
Windows 10
PS 5.0

Hi All -

Is is possible to get the full path/ folder where the deployed EXE is running from?

I've tried the following: $PWD, [environment]::CurrentDirectory, get-scriptdirectory, Split-Path $hostinvocation.MyCommand.path
but none have produced the path of the running exe.

thanks.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Get the full path of the EXE

Post by jvierra »

In a project this is defined for you:

$ScriptDirectory
User avatar
njcappa
Posts: 66
Last visit: Tue Jan 26, 2021 6:59 am

Re: Get the full path of the EXE

Post by njcappa »

As always - thanks for the quick info, Jvierra!

Is there a way that shows the full path including the exe itself, by chance?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Get the full path of the EXE

Post by jvierra »

Look at the function in globals.ps1
This topic is 7 years and 2 weeks 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.
Locked