Call Powershell from Command Prompt Relative Path

Question:

I’m calling a PS script from Command Prompt using the following line

However I need the script to be relative to the command prompt window. So if command prompt was looking at C: then the script would effectively be

Is there a way to inject the relative path?

Answer:


or if you mean to use the directory from which the batch file was launched in the powershell script then you would use a parameter by putting this type of line at the start of your PS script…

Then populating it from the command line invocation like…

Source:

Call Powershell from Command Prompt Relative Path by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply