how would i code an installer?

BlitzMax Forums/BlitzMax Beginners Area/how would i code an installer?

richardsimpo123456(Posted 2009) [#1]
i would like to learn how to code an installer, as it could come in handy one day if i make anything with leadwerks engine XD. I was wondering how it would be done though. I have tried NSIS and their scripting is hard to get my head around, so i thought i would ask here on how to code my own :D


Arabia(Posted 2009) [#2]
Depends where you are at in your programming level I guess.

If I was to do it, first thing would be just working with the file copy, diretory creation etc. functions.

Then maybe at look at:
File1.TXT 9494 Bytes lives in: \userschoice directory
File2.EXE 29394 Bytes lives in: \userschoice directory
data.dat 2345 Bytes lives in: \userschoice directory\data

Combine these files into a single file maybe (need to include a header with file details for each file) and then have your program "expand" these back to the original three files and put them in the correct directory.

Next would be doing the above, but using compression (there is a module for that I recall seeing)

From there...well look at what other installers do (InstallShield etc) and add similar functions and features, I'm sure you'll get a load of requests for added features once you get a solid working base.

Hope that helps (I'm no expert, this is just how I'd probably go about it)


richardsimpo123456(Posted 2009) [#3]
ah thanks :D, yeah im still a newbie at blitzmax. ill try these out soon :D thanks again.


Arabia(Posted 2009) [#4]
No probs :)

I'm still new to BM myself - though I've been programming on and off for the last 25 years or so :)

Biggest tip (and I don't follow this myself most of the time, though I am trying to change) is not to bite off more than you can chew at each stage :)


matibee(Posted 2009) [#5]
Absolutely don't try and roll your own. It'll take forever and not be compatible with Windows installer conventions. Inno Setup scripts are a doddle (if you're coding AT ALL you can it figure out)...

http://www.innosetup.com/isinfo.php


Arabia(Posted 2009) [#6]
@matibee

I'm sorry, but I don't agree


If Visual Basic is the best programming language on earth, then you are saying that no one else (BlitzMax for example) shouldn't write a windows based BASIC compiler? :S

As for Windows installers - who needs to follow their conventions? :S Writing a game in BM doens't mean using a DLL that wsa written for use for every program under than sun.

Then again, maybe I'm missing something :)


matibee(Posted 2009) [#7]
If Visual Basic is the best programming language on earth, then you are saying that no one else (BlitzMax for example) shouldn't write a windows based BASIC compiler? :S


Please don't put words in my mouth. I'm saying nothing of the sort. What I am saying is avoid a tonne of work, because it's pointless and it won't work.

Then again, maybe I'm missing something :)


Show me how your 'file goes here' install script would deal with these three basic installation operations;

Multiple user accounts
Desktop shortcuts and start menu items
Adding an uninstaller

across all known windows installations (heck just the "normal" target ones) in all known languages.


_Skully(Posted 2009) [#8]
Windows does not have the same requirements across distributions... WinXP is different than Window Vista... and likely windows 7. If you use a package that is already built why on earth would you want to re-invent that? Use a known working install packager and just make sure your program supports having userdata separated from the executable.

IMaHO,
Cheers.


markcw(Posted 2009) [#9]
In no particular order.

Inno Setup: http://www.jrsoftware.org/
ClickTeam Install Creator: http://www.clickteam.com/eng/installcreator.php
Nullsoft Scriptable Install System: http://nsis.sourceforge.net/Main_Page
Advanced Installer: http://www.advancedinstaller.com/feats-list.html
More installers: http://en.wikipedia.org/wiki/Installation_(computer_programs)#Common_installers

Other topics on installers.

> Install maker program?
> Zip capability#10
> Blitz Installer


xlsior(Posted 2009) [#10]
As for Windows installers - who needs to follow their conventions? :S


Anyone who actually wants their programs to *work*?

There are a TON of catches: for example, under windows Vista and Windows 7 most computers have UAC (User Access Controls) enabled, which means that program's an't allowed to write to many folders (including the 'program files' one) except at install time. If you don't use the proper windows API's to actually register the software as a proper installation with windows, then UAC will flat out prohibit you from creating folders and writing files there.
Also, be very, very careful not to make any assumptions about file locations: windows isn't always installed on the C:\ drive, and the windows folders aren't always called 'program files', 'documents and settings' etc. either since there are dozens of localized non-English windows editions as well.
On top of that the conventions of where to exactly store your files are different for windows versions as well: under windows 95 you need to do different things than you do under windows 2000 which is different than windows XP which is different than windows Vista.
(don't remember to trigger creating a system restore point under Vista and above, for example!)

Now, does that mean that you shouldn't create an installer yourself?

Not at all, but do realize that there is a LOT more to one that it may seem like at first, and a lot of places where things can go wrong. It's a pretty cumbersom ordeal nowadays to create one that can deal with all the little gotcha's and exceptions that need to be taken into account, and isn't something that you'll just slap together in a day or two.

Personally I'd use an existing one like innosetup in a heartbeat. :-?