Simple 'Automatic' Installer

Share your advanced PureBasic knowledge/code with the community.
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Simple 'Automatic' Installer

Post by utopiomania »

This is a simple 'Automatic' Installer, in the way that if you finish a program and put the program and its files together
with 'Install.exe' in a folder, you can ask users to unzip the folder and run 'install.exe' to install the program.

The installer will copy what's in there to the appropriate folder, create a desktop shortcut, create a program group and
some shortcuts in Start/Programs. It will also create the necessary registry entries to uninstall the program through
Control Panel Add/Remove programs.



To do this properly the Installer looks for some filenames in the folder it runs from:

1) The installed program need to be on the form Name10.exe, a name and some numeric version info. An exe on that
form will be interpreted as Name 1.0, and this will be used to name some elements during the installation process.

2) If it find's an 'Install.png' it will be used for the header background logo. (600x60 px)

3) If it find's a 'licence.txt' it will be used for the required program licence.

4) If it finds a filename containing the word 'help' it will link to it in the program group.

5) If it finds a filename containing the word 'readme' it will link to it too.



The uninstall is clean, provided that your program doesn't add or save anything to the folder it is installed in. If it does,
the original copied files are deleted, but the added files and the folder structure itself are not deleted.



I've put together two demos that install another small app (the htm editor I posted recently). Compare the folder file
contents with the final result to get a grip on how it works:

1) A zipped install. Unzip, open and run install.exe. This folder also contains the installer source, an install.jpg (header
logo), and an install.txt (licence) that you can use (at your own risk).

2) An install using the free MS IExpress program to create a self extracting install package.



Please note that if you compile and run the source directly, the resulting program is created in the compilers folder, not
in the source folder you put the source in, and it is going to attempt to install the compilers folder on your computer if you
click 'Finish', and you will have to remove it manually.

If you want to modify and run the source, create an executable in a test folder and run that instead using a desktop
shortcut to it, but comment out any unwanted actions.... Have fun installing :)

Edit:20071016:
The source to the installer and a licence.txt is now posted below:

here
Last edited by utopiomania on Tue Oct 23, 2007 10:43 pm, edited 10 times in total.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Sounds nice. But page cannot be found :(
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

Sorry for the inconvinience, for some reason the filename 'installer.htm' was inaccessible, but 'Installers.htm' is ok. :?: Hope it's fixed now.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Works very nice here!
And the installer interface looks nice!
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

Very good ! :D And useful 8)
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

Useful.. you say, but how are you going to convert it into a lib?
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

dagcrack wrote:Useful.. you say, but how are you going to convert it into a lib?
Not this time :lol:
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

Image
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

@thefool, and @Droopy, thanks for taking the time to check it out! :) And, if there is any kind of problem with it, I'd like to know.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

np. Ill have a more depth look later today or tomorrow.
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

@dagcrack, could you do me a favour and remove your stupid thread-bomb from my, ehh.. thread?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Works brilliantly. Excellent tool; this will come in very handy.

Thanks for sharing.
I may look like a mule, but I'm not a complete ass.
Jan2004
Enthusiast
Enthusiast
Posts: 163
Joined: Fri Jan 07, 2005 7:17 pm

Post by Jan2004 »

Thanks. U-top Installer is really very good. I have just resigned from Inno Setup - after 6 years of usage.

Jan
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

Hey! Thanks srod and jan2004 for testing! :) Glad it can be of any use, and don't hesitate to tell me of any problems
that needs to be corrected, or anything else.
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

I have just updated it. The Installer now uses ShellExecute_() to run the installed program after the install.

RunProgram() seems to fail if Windows aks for a confirmation before allowing the installed program to run.

Also, because of this confirmation, the Installer window is no longer topmost. And it has got a different header
logo.
Post Reply