0

I want to replace the path in this command:

$Env:PHANTOMJS_BIN='D:\michael\software\phantomjs-1.9.7-windows\phantomjs.exe'

With the output of this call:

Split-Path (Get-Command phantomjs).Path

Preferably using string interpolation. How is this possible in PowerShell?

1 Answer 1

1

It depends whether you want to replace the variable just for the current session or permanent. Also machine-wide or for the user? Here an example to set the environment variable permanent for the machine:

[Environment]::SetEnvironmentVariable("PHANTOMJS_BIN", (Split-Path (Get-Command phantomjs).Path), [EnvironmentVariableTarget]::Machine)

What do you mean with string interpolation?

Sign up to request clarification or add additional context in comments.

2 Comments

The term "interpolation" may come from Perl: "Interpolation, meaning "introducing or inserting something", is the name given to replacing a variable with the value of that variable.". But it is not clear what it means in the context of the question.
In any case, your question does not belong in the answer, but in a comment to the question (Stack Overflow is not a forum). Can you move it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.