<p>The first batch file launches a command prompt, i need the second command to be in the ccontext of the first.  how can I do this in python?</p>

<p>As is, it launches the batch, and blocks until the batch (with its command prompt context) terminates, and then executes <code>devenv</code> without the necessary context.</p>

<pre><code>os.system(r'%comspec% /k ""C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86')
os.system(r'devenv asdf.sln /rebuild Debug /Out last-build.txt')
</code></pre>

<p>think of it as in i'm in bash, and i need to execute a command in a perl context, so i type <code>perl -c 'asdf'</code>.  executing perl and asdf back to back won't work, i need to get the <code>devenv</code> inside of the perl context.</p>

You could append the devenv command onto the end of the original batch file like so:
```
```
'%comspec% /k "...vcvarsall.bat" x86 && devenv asdf.sln /rebuild ...'
```
```
(obviously I have shortened the commands for simplicity's sake)