Do you mean that you want to, from within PowerShell, open the VS-configured
cmd.exe and keep it running? You want precisely what you have when you
launch the VS command prompt from the start menu, but hosted in your current
PowerShell session?
To do that, you simply use the same command as is shown in that shortcut.
For example, I could enter this at a PowerShell prompt for a VS 2005
environment:
cmd /k "c:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86
I would then be running cmd.exe inside the PowerShell window, and can just
type exit to close and return to PS.
If instead you mean you want to have the VS environment variables accessible
from within PowerShell, you actually need to perform some translation work -
fortunately not much of it, though. The VS command prompt shortcuts
typically point to batch files that each launch another batch file and then
somewhere below end up launching vsvars32.bat. That file can be translated
into a PowerShell equivalent, and it's been done before (Keith Hill, for
example, did it over 2 years ago); details will vary, depending on platform
bitness and VS version. For that, post back what you're after. You can also
Google 'vsvars32' and 'PowerShell' together to get a brief set of
discussions of previous forays into this area.
"GS" <GS@xxxxxx> wrote in message
news:28AD52E5-92C8-4301-8337-C061CC615B1C@xxxxxx
> But what if I want to run the visual studio command line prompt batch? I
> mean
> the vsvar32.bat has to set the environment variable. If a command line
> prompt
> were opened, executed the script, and were closed, the Windows PowerShell
> wouldn't be affected.
>
> "Shay Levy [MVP]" wrote:
>
>> Hi PhilW,
>>
>>
>> You can call them simply by their file name or when hosted in cmd:
>>
>> PS > d:\batch.bat
>>
>> PS > cmd /c d:\batch.bat
>>
>>
>> Pipe each file to out-null, doing so will garenty that the script won't
>> proceed
>> until each batch file has finished excuting:
>>
>> d:\batch1.bat | out-null
>> d:\batch2.bat | out-null
>> d:\batch3.bat | out-null
>>
>>
>> out-null will also supress any output generated by the batch files.
>>
>>
>>
>>
>> ---
>> Shay Levy
>> Windows PowerShell MVP
>> http://blogs.microsoft.co.il/blogs/ScriptFanatic
>>
>>
>>
>> P> Possibly a strange question but I have a collection of existing batch
>> P> files that are working perfectly well but I need to call them in
>> P> different a different order to perform different tasks. Is it
>> P> possible to run these from PS if so how is it achieved?
>> P>
>> P> Many thanks
>> P>
>> P> Phil
>> P>
>>
>>
>>