Setups

From HashVB
(Redirected from Setup)
Jump to: navigation, search

So, you have written your application, made it look all wizzy and it works fine. You then go and copy it to a friends PC to test and it crashes. VB applications, like programs written in almost every other language, have runtimes and dependencies. This normally makes your application slightly more complicated than just "copy and run". You need an installer.

There number of options to create a setup for your application as follows:

  1. VB Package and Deployment wizard (PDW)
  2. Microsoft Visual Installer, an addon to Visual Studio
  3. Inno Setup
  4. Wise Installer
  5. InstallSheild
  6. Nullsoft Scriptable Install System (NSIS)

Personally, I have had 1st hand experience of PDW, Visual Installer and Inno, and I find Inno by far the best.

VB PDW has various known issues installing where it can get stuck in a perpetual reboot loop. It is also written in VB so requires a two step install to install the runtimes, and then to run the real setup, often with a reboot in the middle. On top of that, it is not very customisable.

Visual Installer was the next step up and created Microsoft Installer packages. The setup wasn't customisable at all beyond changing the graphics and a few UI elements, and it relied on the ever problematic Windows Installer. This had further problems of not being able to upgrade applications without a full uninstall first.

I then moved onto Inno which was a breath of fresh air. It is based on a text "script" file that lists all the files to be installed to where, icons, UI, extra code, etc... The installer itself is very customisable out the box with options to control which screens the users see, graphics, what they can and cant do. It can also be expanded using a relatively simple Pascal script which allows you to create your own screens, and much more.

This is the basis for this article.

Sample script

This is a sample script created using the Wizard which appears when you first start Inno Setup.

[Setup]
AppName=HashVB Test App
AppVerName=HashVB Test App 2.4
AppPublisher=HashVB
AppPublisherURL=http://www.earlsoft.co.uk/hashvb/
AppSupportURL=http://www.earlsoft.co.uk/hashvb/
AppUpdatesURL=http://www.earlsoft.co.uk/hashvb/
DefaultDirName={pf}\HashVB Test App
DefaultGroupName=HashVB Test App
OutputBaseFilename=setup

[Files]
Source: "C:\Program Files\Inno Setup\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion

[Icons]
Name: "{group}\HashVB Test App"; Filename: "{app}\MyProg.exe"

[Run]
Filename: "{app}\MyProg.exe"; Description: "{cm:LaunchProgram,HashVB Test App}"; Flags: nowait postinstall skipifsilent

This is about the minimum amount required for Inno. It will ask the user where to install the application (defaulting to Program Files\HashVB Test App) and what group on the start menu to put the icons under.

VB Runtimes

To install a VB based application, you will need to make sure that the VB runtimes are installed.

This information is mostly taken from the InnoSetup Knowledge base.

As it is never a good idea to copy files directly from the system directory, you will need to get the most recent redistributable files and extract them into a separate directory. These can be downloaded from The Inno Setup website or direct from the Microsoft Download Center.

;VB system files
Source: "vbfiles\msvbvm60.dll"; DestDir: "{sys}"; OnlyBelowVersion: 0,6; Flags: restartreplace uninsneveruninstall sharedfile regserver
Source: "vbfiles\oleaut32.dll"; DestDir: "{sys}"; OnlyBelowVersion: 0,6; Flags: restartreplace uninsneveruninstall sharedfile regserver
Source: "vbfiles\olepro32.dll"; DestDir: "{sys}"; OnlyBelowVersion: 0,6; Flags: restartreplace uninsneveruninstall sharedfile regserver
Source: "vbfiles\asycfilt.dll"; DestDir: "{sys}"; OnlyBelowVersion: 0,6; Flags: restartreplace uninsneveruninstall sharedfile
Source: "vbfiles\comcat.dll";   DestDir: "{sys}"; OnlyBelowVersion: 0,6; Flags: restartreplace uninsneveruninstall sharedfile regserver

Please note that these are installed by default on windows XP and can't be replaced on Windows Vista so we add the OnlyBelowVersion directives.

As this may be replacing system files, you will need admin privileges to install so I recommend adding this line to the [setup] section:

PrivilegesRequired=admin

Other files

If your application makes use of other files including DLLs, OCXs, etc, you will need to make sure these are installed as well by adding them to the [files] section. All OCX files, and a fair amount of DLL files, will need to be registered so make sure you specify the regserver flag if it is needed. The general rule is to use regserver, and remove it if it errors. You can check this manually by running regsvr32 and passing the filename. If it says the "DllRegisterServer" entry point is not found, it can not be registered.

Source: "ComCtl32.ocx"; DestDir: "{sys}"; Flags: restartreplace sharedfile regserver

See Also