Walkthrough: Deploying a Visual C++ Application By Using the Visual C++ Redistributable Package

Describes how to use the Visual C++ redistributable package to deploy a Visual C++ application.

Prerequisites

You need the following components to complete this walkthrough:

  • A computer with Visual Studio 2010 installed.

  • An additional computer that does not have the Visual C++ libraries.

To deploy an application by using the Visual C++ Redistributable Package

  1. Create and build a new MFC application by following steps 1 through 3 of the procedure in Walkthrough: Deploying a Visual C++ Application By Using the Visual C++ Redistributable Package.

  2. Create a file that is named setup.bat and add the following commands. You need to change MyMFCApplication to the name of the project that you used in step 1.

    @echo off
    vcredist_x86.exe
    mkdir "C:\Program Files\MyMFCApplication"
    copy MyMFCApplication.exe "C:\Program Files\MyMFCApplication"
    
  3. Perform the following steps to create a self-extracting setup file:

    1. Run iexpress.exe from a command window or the Run window.

    2. Select Create new Self Extraction Directive file and click Next.

    3. Select Extract files and run an installation command and click Next.

    4. Enter the name of your MFC application into the text box and click Next.

    5. On the Confirmation prompt page, select No Prompt and click Next.

    6. On the License agreement page, select Do not display a license and click Next.

    7. On the Packaged files page, add the following files and then click Next:

    • Your MFC application (.exe).

    • vcredist_x86.exe. You can find this file in the \Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\vcredist_x86 folder under your Program Files folder.

    • The setup.bat file that you created in step 2.

    1. On the Install Program to Launch page, enter the following in the Install Program text box and click Next:

      cmd.exe /c "setup.bat"
      
    2. On the Show window page, select Default and click Next.

    3. On the Finished message page, select No message and click Next.

    4. On the Package Name and Options page, enter a name for your self-extracting setup file, ensure that the Store files using Long File Name inside Package option is selected, and click Next. The file name must end in Setup.exe (for example, MyMFCApplicationSetup.exe).

    5. On the Configure restart page, select No restart and click Next.

    6. On the Save Self Extraction Directive page, select, Save Self Extraction Directive (SED) file and click Next.

    7. On the Create package page, click Next.

  4. Run the self-extracting setup file on a second computer that does not have the Visual C++ libraries.

    1. Copy the self-extracting setup file that you created in step 3 to the second computer.

    2. Run the self-extracting setup file on the second computer. Follow the steps that are provided by the setup wizard to complete the installation.

  5. Run the MFC application. The self-extracting setup file installs the MFC application that is in the folder that you specified in step 2.

    The application runs successfully because the Visual C++ Redistributable Package installer is included in the self-extracting setup file.

See Also

Concepts

Deployment Examples