Skip to content

Instantly share code, notes, and snippets.

@inh3
Created June 6, 2014 02:32
Show Gist options
  • Save inh3/70f42224a76ca4ab1287 to your computer and use it in GitHub Desktop.
Save inh3/70f42224a76ca4ab1287 to your computer and use it in GitHub Desktop.
Execute nvmw from PowerShell
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