Making an installer?

This is a discussion on Making an installer? within the C++ Programming forums, part of the General Programming Boards category; Ok, I want to make a mini-installer for my program (Just moves the files from one spot to the other). ...

  1. #1
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379

    Making an installer?

    Ok, I want to make a mini-installer for my program (Just moves the files from one spot to the other). I thought the easiest way to make one, would be to use dos commands, but I dont know how to execute thoes, and I'm not sure if it can create a folder. So, as an alternative, I thought why not just move all the files from one spot to another? So, I attempted this, then realize I have no idea how to move files :P.

    So, naturaly the first spot I looked was at the System commands, sure enough:

    Code:
    System("move(blah, blah)");
    This complicates my probelm because I dont know how to use the system command either >.<. I've heard its unsafe to. So, I dug for an alternative, a few premade installers came up, nothing opensource.

    So, my question is, how do I make a relatively safe installer? And, could you provide a quick example of moving one file to the another directory?

    (PS) Is system the base for executing commands? (Like if I type in del, is it taking the del.whatever file from system?)
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  2. #2
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    I'm certain there are Open Source installers - I'm pretty sure I've looked before. I use InstallShield for MSVC 6 but I think it came with my Visual Studio 6 (Enterprise) and I doubt you can download it (legally at least).

    Have a look around Sourceforge if you haven't already.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,301
    A couple of installers that can be downloaded are freely available are Inno Setup and NSIS (Nullsoft Scriptable Install System). I'm sure there are others. If the two, Inno Setup is somewhat easier to use, but NSIS has a lot more features if you are doing fiddly installs.

  4. #4
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469

    winzip

    recent editions of winzip have a feature called self extractor, that'll do what you're looking for, both quickly and easily - get your hands on winzip 7.0 though, cos winzip 9.0 has a nag screen waiting for anyone who tries to run the extractor file If you wanted to write a program that does it, as a personal challenge, then thats up to you

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Or you can use WinRAR, which I prefer.

    (Just moves the files from one spot to the other)
    You can do that with the system command:
    Code:
    system(string("move " + original_file + " " + new_file).c_str());
    (You could use copy instead of move.) But system() is non-portable, unsafe, etc.

    There is no standard C/C++ function for copying/moving a file. But you can copy it yourself and then use remove() (in <cstdio>, I think; might be <cstdlib>) to delete the original file.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    and I'm not sure if it can create a folder.
    Sure you can.
    Code:
    system("md C:\\directory");
    So, my question is, how do I make a relatively safe installer? And, could you provide a quick example of moving one file to the another directory?
    It's pretty simple. Open the original file for binary reading, and the destination file for binary writing. Copy every character over. Close both files. remove() the original file (if you want).

    Here's a remove() example:
    Code:
    remove("oldprogram.exe");
    char oldprogram[] = "oldprogram2.exe";
    remove(oldprogram);
    string oldprogram3 = "oldprogram3.exe";
    remove(oldprogram3.c_str());
    (PS) Is system the base for executing commands? (Like if I type in del, is it taking the del.whatever file from system?)
    Windows used to be just a wrapping on top of DOS. (Now it's the other way around.) The DEL command (or ERASE) deletes a file, MOVE moves one (not available on really ancient DOSes), COPY copies one, REN/RENAME renames one, etc.

    In DOS, MOVE is the same as MovE or move. Unlike Linux.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    I would recommend Inno Setup, i've been using it for a while now, and it is really good.
    My Website
    010000110010101100101011
    Add Color To Your Code!

  8. #8
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    I'm not using serious installers cause they're 3 files . +The directory needs to be very specific, I hardcoded all my paths in -,- (noobie mistake >.<). Thank you for the help!
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  9. #9
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    For what it's worth, MS made one of their installers an open-source project, too. You just need to write the XML file that controls it by hand.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linux software installer recommendations
    By BobS0327 in forum Tech Board
    Replies: 13
    Last Post: 09-24-2006, 01:19 AM
  2. Making great graphics
    By MadCow257 in forum Game Programming
    Replies: 1
    Last Post: 02-20-2006, 10:59 PM
  3. Making an installer package using a console app
    By Finchie_88 in forum C++ Programming
    Replies: 22
    Last Post: 10-23-2004, 09:30 PM
  4. Replies: 2
    Last Post: 01-13-2003, 12:28 PM
  5. About Unix Programming - Making a career desision
    By null in forum C Programming
    Replies: 0
    Last Post: 10-14-2001, 07:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21