Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get script path

Status
Not open for further replies.

CluM01

MIS
Sep 26, 2011
4
0
0
US
Hello,

I am working on a Windows form using PowerShell. I need to generate a file from the form application and place the file in the script's executable path. I have the function below which I use for getting the script path in a command console mode, but it does not return any value when I launch it in the Windows form.

function get-ScriptPath {
if($MyInvocation.ScriptName)
{$scriptPath = $MyInvocation.ScriptName}
else
{$scriptPath = $MyInvocation.MyCommand.Definition}
Split-Path -Parent $scriptPath
}

I want to know if there is any way I can do to get the Windows form's executable path.

Thank you in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top