Creating auto-install software for Windows

This blog post is all about the fun I have had getting a C# application I have developed for the pedalog (pedal power monitor) to run as an easy-to-install .exe file. I thought this would be easy and it probably is to folk who have done it before…

Firstly I had written an application using C# and the .NET framework using Visual Studio Express (the free version from Microsoft). I am not going to go into C# code at the moment but this application calls a custom driver. This driver converts what comes from the C# program into the language of the plugged in device (talking over USB), hence the device (pedalog) can talk to the computer and display information.

The problem is that the driver is a custom one and is not already installed on a typical Windows set-up. This driver can be downloaded and installed, but this is an annoying step which should be automatic and I wanted to make an easy-to-install package that anyone could easily and quickly use. I wanted to create a co-installer which looks to see if the driver has been installed and, if not, installs it, then it goes on to install the C# application which uses the driver.

As usual a google search find a wealth of information, but with conflicting information and lack of detail which I required. I eventually found this application paper from Microsoft, which started me down the right path…

It led me to look at the Windows Driver Kit (downloadable here) which has the various tools for producing drivers and co-installers. It seems way over-technical to me at the moment. Lets see how it goes….

The Windows Driver Kit is obviously a powerful set of tools to produce drivers for products. It also helps to create driver install program, which is just a very small part of it. I already had my driver which I knew worked, but wanted to create and distribute an easy-to-install program. The Windows Driver Kit is available as an .iso image which I burned to a CD and then installed on my computer (I use windows XP and Linux-Ubuntu on a daily basis but this was just for windows users). It creates a Folder on the C:/ drive called WinDDK.

To do this I used a part of the the Driver Kit called Driver Package Installer (DPInst). This is within the directory C:\WinDDK\7600.16385.1edist\DIFx\dpinst\EngMui\x86 and is labeled dpinst.exe.

To make everything work correctly you need to put a number of files together within a folder this includes:

dpinst.exe (from C:\WinDDK\7600.16385.1edist\DIFx\dpinst\EngMui\x86)

dpinst.xml (from C:\WinDDK\7600.16385.1\src\setup\DPInst)

eula.txt (from C:\WinDDK\7600.16385.1\src\setup\DPInst)

toaster.icon (from C:\WinDDK\7600.16385.1\src\setup\DPInst)

ToasterRad.bmp (from C:\WinDDK\7600.16385.1\src\setup\DPInst)




This is .xml code within the dpinst.xml file. I had to add the line to switch ON legacy mode. This is because the driver is not digitally signed (this is a security aspect). The dpinst.xml for my application looks like:

I have changed a few things to ensure it all looks nice and is specific to my device. You can change the wording, you can add you own end user license agreement along with icon (Favicon.ico).

When dpinst.exe is run then it will automatically pull in the info required and install the driver.

You then need to make this a self-extracting installation. To do this I used IExpress. Go to Start> Run then type in “IExpress” which runs a wizard to create a self-extracting package. The package must all be in the same folder to use the program easily (I’m sure you can change this but I could not do it easily). Follow the IExpress wizard and add all the files mentioned above. This then creates a single self-extracting .exe application file.

So now I have a self-extracting driver, which is great. But my main goal was to have a self-extracting driver and then program install….

It seems that to install an application and the driver associated with that application you can use another part of the DIFx package (from where the DPInst came from) which is called DIFxApp. But before that you should look into using windows installer package

This page seems to have to options for creating a deployment package.

After researching this a bit more and a lot more head-banging it seems that the free Visual Studio 2010 Express version does not have a setup project available. This means that you can only use the ClickOnce system for creating published C# projects.

In order to produce a downloadable program you right-click on your project in the Solution Explorer panel of visual studio. Then click on “Publish” and follow the wizard which pops up. This creates a set of files which are suitable for putting onto a disk for delivery with the product. This is not a self-extracting file, but is relatively simple to install.

Edit 19/3/2011:

I have now used a program called 7zip to create a self-extracting .exe program (following these instructions). This will extract the files to wherever the user specifies. They can then run setup.exe which will install and run the application.

So in the end I could not get exactly what I wanted. I now have two downloads – one for the driver and one for the application.

Edit 7/4/2011:

I was told about free-ware installer program writing called NSIS (The Nullsoft Scriptable Install system). This program does exactly what I want and is free for commercial use. It is a script based language so takes a little bit of getting used to, if you are more comfortable with GUI programs. I would recommend starting with the very basic ‘simple tutorials’ and go from there.

After I had written my code I also found out about HM NIS edit which creates the script from a very easy to use wizard.

It was not all plain sailing after finding out about this program. I already had built my driver installation program. This checks for the .NET framework and installs the driver in the correct places on multiple operating systems. NSIS did not seem to be able to do a similar thing without lots of hassle (checking OS etc). So I wanted to run the driver installer from within the NSIS interface installer.

This turned out to be very easy. I added the line:

ExecWait “reinnovation_driver.exe”

This executes and waits until that has finished before carrying on. “reinnovation_driver.exe” was the name of my driver install program.

Also I did not use the one-click version of my C# program. This would have re-installed the program, which I did not want to do. I found the relevant parts required for the program to run. This turns out to be only 2 files – the .exe file found in the bin folder (this is the actual application) and a .dll file which I needed to do some graph facilities. These are installed into a user selected directory.

In the end the install program works really well and looks nice. Its also very easy and intuitive. I recommend NSIS wholeheartedly for this process.

Please have a look at the pedalog in the projects section for a link to the .exe installer I created.

Leave a Reply

Your email address will not be published. Required fields are marked *