Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to script Visual Studio 2008 from Python?

I'd like to write Python scripts that drive Visual Studio 2008 and Visual C++ 2008. All the examples I've found so far use win32com.client.Dispatch. This works fine for Excel 2007 and Word 2007 but fails for Visual Studio 2008:

import win32com.client
app1 = win32com.client.Dispatch( 'Excel.Application' ) # ok
app2 = win32com.client.Dispatch( 'Word.Application' )  # ok
app3 = win32com.client.Dispatch( 'MSDev.Application' ) # error

Any ideas? Does Visual Studio 2008 use a different string to identify itself? Is the above method out-dated?

like image 226
jwfearn Avatar asked Oct 21 '08 16:10

jwfearn


1 Answers

I don't know if this will help you with 2008, but with Visual Studio 2005 and win32com I'm able to do this:

>>> import win32com.client
>>> b = win32com.client.Dispatch('VisualStudio.DTE')
>>> b
<COMObject VisualStudio.DTE>
>>> b.name
u'Microsoft Visual Studio'
>>> b.Version
u'8.0'

Unfortunately I don't have 2008 to test with though.

like image 55
ryan_s Avatar answered Oct 07 '22 00:10

ryan_s