Add Start Menu Uninstall Icon to your VB Projects

Submitted on: 1/31/2015 11:08:00 AM
By: Christopher Reason (from psc cd)  
Level: Beginner
User Rating: By 11 Users
Compatibility: VB 6.0
Views: 1393
     This article will detail in 10 easy steps how to create your own Uninstall icon (and place it in the Program Group) for every VB project that you create. PLEASE, TAKE AN EXTRA MINUTE TO VOTE FOR THIS ARTICLE IF YOU LIKE IT. Thanks, Christopher.

This article has accompanying files

This article will detail in 10 easy steps how to create your own Uninstall icon (and place it in the Program Group) for every VB project that you create. The problem with P&D Wizard is that it will not allow you to create an icon in the icon group that points to St6unst.exe (the uninstaller for VB). I have created program for my family, they have installed them, and then in their infinite wisdom, simply gone into My Computer and deleted the folder(s) for the program not realizing that they must go to Add/Remove Programs to uninstall it from there. This deletes the St6unst.log file and thus renders the uninstall process null and void! So we are going to provide "computer illiterate" people (like my family) with another icon, in the start menu of your program, to uninstall your program!

Before we get started, just a quick note to help you read the article better. Any text in Italics will denote text that is optional or can be renamed as you choose. Ok, let's get started!

  1. Create a new Standard Project in VB, add one Form and one Module (bas) to the project.
  2. Rename the Project Uninstall, and the Module unInstall.
  3. Add an icon to Form1 (the form does not really need to be renamed as the form will only be used for its icon), I use the icon located at Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Win95\RECYFULL.ICO.
  4. In the unInstall module add a "Sub Main". Go to Project Properties and set "Sub Main" as the startup object. While in the Project Properties, click on the Make Tab and click on the Icon dropdown to select Form1. This sets your executables Icon to the icon you chose for Form1.
  5. In Sub Main add the following lines of code (this is the only code needed for your uninstaller program) which will open the Add/Remove Programs Dialog of the Control Panel:

    Sub Main()
    'opens the Add/Remove Programs dialog of the Control Panel
    Shell "rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,1"
    End Sub
  6. Save the project to it's own folder (location of your choice) and compile the project to the same folder.
  7. Now, whenever you package a project, include this Unistall.exe file with your other project files. During the Package process, when you get to the Included Files, click the Add button and navigate to the folder where you compiled the Unistall.exe program and include that file with your current project.
  8. A few steps later in the Start Menu Items step, click New Item. Name the New Item Uninstall APPNAME (where APPNAME is the name of the application that you are currently packaging).
  9. Set the Target for this New Item to the Uninstall.exe file.
  10. In the next step, Install Locations, be sure that the install location for your Uninstall.exe file is the ($AppPath) macro.

You've done it! A very simple, easy way to safe guard your users from, well, themselves! Now every time they go to the start menu to run your program, they will see the "Uninstall" icon there as well. When they click on this Uninstall APPNAME icon, it will open the Add/Remove Programs Dialog of the Control Panel and prompt them to uninstall the program from there!

I hope that you find this article useful. If you do please be sure to come back and vote! I would appreciate your votes AND comments too. Hope you have a great day!


winzip iconDownload article

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net

Other 4 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.