How to run an existing Visual Studio .NET or Visual Studio 2005 Wizard by using DTE.LaunchWizard

Article translations Article translations
Article ID: 315487 - View products that this article applies to.
This article was previously published under Q315487
Expand all | Collapse all


The sample code provided in this article demonstrates how to use the LaunchWizard method of the DTE object to run an existing Microsoft Visual Studio .NET Wizard.


The DTE.LaunchWizard method requires two arguments when used to run a new project wizard. The first argument is the name of the wizard file (.vsz file). The second argument is an array of values that is passed to the wizard when it runs. When you set the seventh element of the array to True, you can force the errors to throw exceptions, which may be caught in a try...catch structure. The New Windows Application Wizard expects the following values in the array:
  • WizardType: a GUID indicating the type of wizard. For a new project wizard, the GUID is {0F90E1D0-4999-11D1-B6D1-00A0C90F2744}.
  • ProjectName: a string for the name of the new project.
  • Local directory: a string containing the full path to the folder where the new project will be created.
  • Installation directory: a string containing the folder where Visual Studio is installed.
  • Exclusive: a Boolean value indicating whether any existing open solution should be closed.
  • Solution name: a string name for the solution file, without a path or extension.
  • Silent: a Boolean indicating whether the wizard should run silently.
The following macro shows how to use the LaunchWizard method to run the existing wizard.

NOTE: The macro uses the Silent flag when calling the wizard. If you run this macro once, it runs without error, provided that the directory and project do not already exist. If you run this macro a second time, an error is raised. Because the Silent flag is set to True, an exception is caught by the try...catch block.
Sub LaunchWizardExample()

Dim params() As Object = New Object() 
   "{0F90E1D0-4999-11D1-B6D1-00A0C90F2744}","NewProjectName1","NewProjectPath", "", False, "", False
'The last value is the "Silent" flag where TRUE=No UI, FALSE=UI

Dim res As EnvDTE.wizardResult
Dim s As String = DTE.Solution.TemplatePath(VSLangProj.PrjKind.prjKindCSharpProject)
   res = DTE.LaunchWizard(s & "CSharpEXE.vsz",params)
Catch e1 As System.Exception
   System.Windows.Forms.MessageBox.Show("Caught an Exception: " + e1.Message)
End Try

End Sub
For additional information about the Wizard type, search on ContextParams Enum in Books Online.


For more information about troubleshooting Visual Basic .NET and Visual C# extensibility, browse to the Microsoft Web Help file at the following Microsoft Web site:


Article ID: 315487 - Last Review: January 12, 2006 - Revision: 3.4
  • Microsoft Visual C++ .NET 2002 Standard Edition
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ 2005 Express Edition
kbhowto KB315487

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from