How to execute a .BAT file (batch script) during or automatically after a Visual Studio Created Install/Setup Program?

Posted on 2006-04-05
Last Modified: 2008-01-09
Hello everyone,

I have created an installation "Setup Wizard" using Visual Studio 2003 for my C++ application. I have created a .BAT batch script that basically runs some command prompt commands to create a new user and a password for that user.

Currently the Install program just places the .BAT file on the users desktop for them to run after installation. It doesn't automatically run it after or during the installation.

How can I make it so that it either executes the .BAT file during or after the installation of my C++ program?

Again please note I'm using the standard Visual Studio 2003 "Setup Wizard" to create an installation/setup program that installs my C++ program on the users PC.

Thanks in advance.
Question by:VirtueTech
    LVL 48

    Expert Comment

    I have VS 2005, hopefully in VS 2003 this is the same.
    In Solution Explorer select project item, clock "Properties" tab. Properties contain PostBuildEvent - specifies any commands to execute after the build ends.

    Author Comment

    I checked and I don't see it. Looks like it might be VS 2005 only. Too bad...that would have been perfect.

    Thanks for the reply.

    Anyone else have an idea?
    LVL 10

    Accepted Solution


    You can perform the following steps in order to do what you want. The problem is that only .exe, .dll, .vbs and .js files are supported but not .bat ones.
    1. Select the setup project name;
    2. In the Solution Explorer toolbar you'll find some new buttons. Click on the Custom Actions Editor.
    3. In the Custom Actions window select Install node of tree
    4. Go to Action menu and select Add Custom Action
    5. Select Application folder from the combobox labeled Look in
    6. Add file
    7. Select All files, the click Add File
    8. Browse and select the desired file
    9. Build your solution.

    So, you have to create a .vbs file instead of your .bat one
    LVL 15

    Assisted Solution

    >>Currently the Install program just places the .BAT file on the users desktop for them to run after installation. It doesn't automatically run it after or during the installation.

    You can also select 'User's desktop' instead of Application folder in step 5.

    You would be able to run the batch file itself during the installation if you choose the file type as 'All files'

    Author Comment

    Thanks guys....going to give it a shot tonight

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now