title: Setting up Visual Studio environment variables from PowerShell
body: <p>I have Visual Studio 9.0 installed but I want to use it manually from PowerShell. It comes with two setup scripts: <code>vcvars32.bat</code> for the 32-bit compiler and <code>vcvars64.bat</code> for the 64-bit compiler. When I open <code>cmd.exe</code> and run one of the scripts, it sets up everything just fine and I can run <code>cl.exe</code> without any problems. When I run one of those setup scripts from PowerShell, though, it doesn't work. The scripts run through fine but trying to run <code>cl.exe</code> afterwards yields a "<code>cl.exe</code> could not be found" error! And looking at the contents of the <code>PATH</code> environment variable after running one of the setup scripts I can see that <code>PATH</code> hasn't actually been modified at all.</p>
  
  <p>So it seems as if the batch files ran from PowerShell maintain their own environment variables state which goes away as soon as the batch file terminates. So is there a way to run batch files from PowerShell and have those batch files affect the actual environment variables of the current PowerShell session? Because that is what I need. All that is done by <code>vcvars32.bit</code> and <code>vcvars64.bit</code> is setting up environment variables after all but it only seems to work from <code>cmd.exe</code>, not from PowerShell. </p>