Created
June 6, 2014 02:32
-
-
Save inh3/70f42224a76ca4ab1287 to your computer and use it in GitHub Desktop.
Execute nvmw from PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-StrictMode -Version 3 | |
# create temp file to store batch local env | |
$tempFile = [IO.Path]::GetTempFileName() | |
Invoke-Command -ScriptBlock { cmd /c "nvmw.bat $args && set > `"$tempFile`"" } -ArgumentList $args -NoNewScope | |
# find path variable and set path | |
Get-Content $tempFile | Foreach-Object { | |
if($_ -match "^(PATH)=(.*)$") | |
{ | |
Set-Content "env:\$($matches[1])" $matches[2] | |
} | |
} | |
# remove the temp file | |
Remove-Item $tempFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment