How to resolve the algorithm Program name step by step in the PowerShell programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Program name step by step in the PowerShell programming language

Table of Contents

Problem Statement

The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal ARGV. See also Command-line arguments Examples from GitHub.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Program name step by step in the PowerShell programming language

Source code in the powershell programming language

# write this in file <program.ps1>
$MyInvocation.MyCommand.Name 
# launch with <.\program>


  

You may also check:How to resolve the algorithm Topological sort step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Roots of a function step by step in the REXX programming language
You may also check:How to resolve the algorithm File size step by step in the Raku programming language
You may also check:How to resolve the algorithm Binary strings step by step in the Prolog programming language
You may also check:How to resolve the algorithm Quoting constructs step by step in the jq programming language