Introduction
I recently ran into a problem when it came around to deploying my first .NET application. When you create a MSI setup file, you can't have it install .NET framework with it. I did some research and found that Microsoft does have some C++ code that you can modify to install the .NET framework for you. Me not knowing much C++ code did get it to compile and install .NET framework before the MSI file, but I needed it to do more.
- Check that the computer had minimum requirements to install the .NET framework.
- Install ADO 2.7 SP1.
- Install the .NET Framework SP2.
The Code
So, I fired up the old Visual Studio 6 and started to right a VB .exe to install these programs. I knew most of my audience would have the VB6 run time because there are some applications that most people use on which are systems that were written in VB6.
To make my job a little easier, I looked around for an object that I could use that would detect the OS for me. I found one written by Eswar Santhosh here, which I have asked him if I could include it with my posting.
I then went ahead and grabbed some code snips from Google Groups to read the registry using only API calls. I did this because I wanted to not be dependent on anything besides the VB run time. I also grabbed some code to execute command line strings using the Windows API calls.
I then wrote a series of if
statements checking to make sure they were running Windows 98 or above. I checked to make sure they were running IE 5.01 or higher. I checked to make sure that if they were running Windows 2000, that they had SP2 or higher. The last check was if they are running NT4, then they are running SP6.
After that, it was easy to right a couple of statements to execute the install code. To make it all run, you need to have these downloads including the source code for this article.
Go in and create your MSI file. Once that is complete, copy everything it creates (InstMsiA.Exe, InstMsiW.Exe, Setup.Exe, Setup.Ini) into an empty directory. Rename the Setup.exe to MsiSetup.exe. Rename the Setup.ini file to MsiSetup.ini. Now copy the setup.exe file that comes with my source code into the directory. You should now be able to run the setup.exe file and it will install everything you need.
Some extras
I went back after testing the install a couple times and added some code for debugging. I added one flag /T for testing. It will just do the checks and alert you what it would have installed if it were going to run. I also added a display form flag /D so you could see the current status of the install.
Summary
That's about, it I wanted to share it with everyone. I felt there might be other people who were frustrated with this. A couple of things that I want to add are, if it's an earlier version of IE, just upgrade it. This might help the Help Desk people who are going to have to go around to 400+ workstations and install it. The code has not been fully tested on Windows 98 or Windows XP. If you find any problems, please email me.
Thanks for listening to me ramble on.