Share via


Walkthrough: Creating a Custom Action

The following walkthrough demonstrates the process of creating a DLL custom action to direct a user to a Web page at the end of an installation.

To create the custom action

  1. On the File menu, point to New, and choose Project.

  2. In the New Project dialog box, select Visual Basic Projects in the Project Type pane, and then choose Windows Application in the Templates pane. In the Name box, type OpenWeb.

  3. Click OK to close the dialog box.

    The project is added to Solution Explorer.

  4. On the Project menu, choose Add Module, then select Module in the Add New Item dialog box. Click OK to close the dialog box.

  5. In the Code Editor, add code to Module1 to open a Web page:

    ' Visual Basic
    Public Sub Main()
       Process.Start("https://www.microsoft.com")
    End Sub
    
  6. In Solution Explorer, select the OpenWeb project. On the Project menu, choose Properties.

  7. In the OpenWeb Property Pages dialog box, select the Startup object property and set it to Sub Main. Click OK to close the dialog box.

  8. On the Build menu, choose Build OpenWeb.

To add a deployment project

  1. On the File menu, point to Add Project, and select New.

  2. In the Add New Project dialog box, select Setup and Deployment Projects in the Project Type pane, and then choose Setup Project in the Templates pane. In the Name box, type Custom Action Installer.

  3. Click OK to close the dialog box.

    The File System Editor is displayed.

  4. In the File System Editor, select the application folder. On the Action menu, point to Add, and choose Project Output.

  5. In the Add Project Output Group dialog box, select the primary output for the OpenWeb project. Click OK to close the dialog box.

To add the custom action

  1. Select the Custom Action Installer project in Solution Explorer. On the View menu, point to Editor, and choose Custom Actions.

    The Custom Actions Editor is displayed.

  2. In the Custom Actions Editor, select the Install node. On the Action menu, choose Add Custom Action.

  3. In the Select Item in Project dialog box, double-click the Application Folder.

  4. Select the Primary output from OpenWeb item.

  5. Click OK to close the dialog box.

  6. In the Properties window, select the InstallerClass property and set it to false.

  7. On the Build menu, choose Build Custom Action Installer.

To install on your development computer

  • Select the Custom Action Installer project in Solution Explorer. On the Project menu, choose Install.

    This will run the installer and install Custom Action Installer on your development computer. At the end of installation, Internet Explorer should be launched and should open the Microsoft.com Web site.

    Note   You must have install permissions on the computer in order to run the installer.

To deploy to another computer

  1. In Windows Explorer, navigate to your project directory and find the built installer. The default path will be \documents and settings\yourloginname\Custom Action Installer\project configuration\Custom Action Installer.msi. The default project configuration is Debug.

  2. Copy the Custom Action Installer.msi file and all other files and subdirectories in the directory to another computer.

    Note   To install on a computer that is not on a network, copy the files to traditional media such as CD-ROM.

  3. On the target computer, double-click the Setup.exe file to run the installer.

    At the end of installation, Internet Explorer should be launched and should open the Microsoft.com Web site.

    Note   You must have install permissions on the computer in order to run the installer.

To uninstall the application

  1. In the Windows Control Panel, double-click Add/Remove Programs.

  2. In the Add/Remove Programs dialog box, select Custom Action Installer and click Remove.

  3. Click OK to close the dialog box.

    Tip   To uninstall from your development computer, on the Project menu, choose Uninstall.

See Also

Custom Actions | Custom Actions Management in Deployment