Reputation: 28770
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?
Upvotes: 0
Views: 1016
Reputation: 58931
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?
Upvotes: 1