HOW TO: Run an Executable File During a Windows Installer Installation by Using Visual Studio .NET (827018)
The information in this article applies to:
- Microsoft Windows Installer
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Academic Edition
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
SUMMARYThis step-by-step article describes how to run an
executable (EXE) file during a Windows Installer installation by using Visual
Studio .NET. This article describes how to create an EXE file to direct users to the Microsoft home page. It also describes how to
add the EXE file as a custom action in a Visual Studio .NET Setup
project. Sometimes, you may want your setup application to perform actions
that Windows Installer cannot do. For example: - You may want to direct users
to your Web site.
-or- - You may want to create a local database on the destination
computer during your installation.
Windows Installer provides features that
are named custom actions. Custom actions help you to create setup applications that perform actions that Windows Installer cannot do. You can add custom actions to your setup application that run code at the end of your installation. This code can be a DLL, an EXE file, a script, or an
assembly. back to the topRequirementsThe following list outlines the recommended hardware, software,
network infrastructure, and service packs that you need:
- Microsoft Windows 2000, Microsoft Windows XP, or Microsoft
Windows Server 2003
- Microsoft Visual Studio .NET
This article assumes that you are familiar with the following
topics:
- Visual Studio .NET Setup Projects
- Custom Actions
back to the topCreate an EXE FileTo create an EXE file to direct users to the Microsoft home page,
follow these steps:
- Start Visual Studio .NET.
- Create a new Empty Project. To do this, follow these steps:
- On the File menu, point to
New, and then click Project.
- Under Project Types, click
Visual Basic Projects.
- Under Templates, click
Empty Project.
- In the Name text box, type
MyEXE. Click OK.
- Add a reference to the System.dll file to your project. To do this, follow these steps:
- On the Project menu, click Add
Reference.
- In the Add Reference dialog box, click
System.dll, and then click Select.
- Click OK to add a project reference to
the System.dll file to MyEXE.
- Import the System.Diagnostics
namespace to your project: To do this, follow these steps:
- On the View menu, click Property
Pages.
- In the left pane of the MyEXE Property
Pages dialog box, click Imports.
- Type the following text in the Namespace
text box, and then click Add
Imports:
- Click OK to import the System.Diagnostics
namespace to MyEXE.
- Add a module to your project to direct users to the Microsoft home page. To do this, follow these steps:
- On the Project menu, click Add
Module.
- In the Add New Item - MyEXE dialog box,
click Open. By default, Module1.vb is created.
- In the Module1.vb file, locate the following statement:
Module Module1 - Add the following code after the Module Module1 statement:
Sub Main()
' Open the Microsoft home page in your default Web browser.
Process.Start("http://www.microsoft.com")
End Sub
- On the Build menu, click Build
MyEXE.
back to the topCreate a Setup ProjectTo create a Setup project, follow these steps:
- On the File menu, point to Add
Project, and then click New Project.
- Under Project Types, click
Setup and Deployment Projects.
- Under Templates, click
Setup Project.
- In the Name text box, type
MySetup. Click OK.
back to the topAdd the EXE File to Your Setup ProjectTo add the EXE file that you created in the
" Create an EXE File" section of this
article to your Setup project, follow these steps:
- In the File System Editor, click Application
Folder.
- On the Action menu, point to
Add, and then click Project
Output.
- In the Add Project Output Group dialog
box, click Primary output to select the primary output of
MyEXE, and then click OK.
back to the topAdd a Custom Action to Run the EXE FileTo add a custom action to run the EXE file that you added to your
Setup project in the " Add the EXE File to Your Setup Project" section of this article, follow these steps: - On the View menu, point to
Editor, and then click Custom
Actions.
- In the Custom Actions Editor, click
Install.
- On the Action menu, click Add
Custom Action.
- In the Select Item in Project dialog box,
double-click Application Folder.
- Click Primary output from MyEXE (Active),
and then click OK.
- On the View menu, click Properties
Window to select the Properties window for the custom action that you
added in step 5.
- To specify that your custom action is not a Microsoft .NET Framework
ProjectInstaller class, change the value of the InstallerClass property to False.
back to the topVerify That Your Application Works- On the Build menu, click Build
MySetup.
- Start Windows Explorer.
- Locate the Setup.exe file that
you built in step 1.
Setup.exe is located in the MySetup\Debug folder. The MySetup folder
is where you created your Setup project in the
"Create a Setup Project" section of
this article. - Run the Setup.exe file.
- In the MySetup dialog box, click
Next three times to start installing MySetup on your
computer.
MySetup is installed on your computer and you are directed
to the Microsoft home page in your default Web browser. - On the Installation Complete page, click
Close to quit your installation.
back to the
topREFERENCESFor more information, visit the following Microsoft
Developer Network (MSDN) Web sites: back to the
top
Modification Type: | Minor | Last Reviewed: | 5/23/2005 |
---|
Keywords: | kbCustomAct kbPDWizard kbIDEProject kbAppSetup kbsetup kbDeployment kbHOWTOmaster KB827018 kbAudDeveloper |
---|
|
|
©2004 Microsoft Corporation. All rights reserved.
|
|