Run Visual Studio command line tools in Windows Powershell

powershellvisual studio 2005

In cmd.exe, I would simply run

%VS80COMNTOOLS%\vsvars32.bat

to set up the environment for running the Visual Studio command line tools (i.e. cl, link, mt, etc.). I wonder how I can set up the environment for running these tools in the Powershell. Sure, it is possible to run batch files using

start-process $env:vs80comntools\vsvars32.bat

but then the environment would be gone when the process terminates. I have already done some experiments with System.Diagnostics.StartProcessInfo, i.e.

$proc = start-process $env:vs80comntools\vsvars32.bat -passthru
$procInfo = proc.StartInfo

and then get the environment from $procInfo.EnvironmentVariables but this also does not work.

Are there any other ways to set up the environment in Powershell?

Best Answer

The PowerShell Community Extensions has an Import-VisualStudioVars cmdlet.

Related Question