A program that kills itself...and questions

This is a discussion on A program that kills itself...and questions within the C Programming forums, part of the General Programming Boards category; I am writting an Install program that will use a series of cds. The Install program will need to access ...

  1. #1
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765

    A program that kills itself...and questions

    I am writting an Install program that will use a series of cds.
    The Install program will need to access each cd.
    It will continue straight through as a several step program.
    How do you get the file running so it can ask for cds as it needs them (temp file on HDD maybe?).
    If a temp file is required, and the Install program gets copied to the HDD, how do you make a C program delete itself?

    Sorry if this isn't a "C enough" question but I'm looking to stray away from Windows stuff and any Windows installers.
    Suggesting replies or PM's are welcomed.
    The world is waiting. I must leave you now.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The easiest way:
    Code:
    #include "filelist.h"
    int main( void )
    {
        int x, cd=1;
        FILE *fp;
        for( x = 0; filelist[x]; x++ )
        {
            fp = fopen( filelist[x], "r" );
            if( fp == NULL )
            {
                prompt_for_cd( cd++ );
                x--;
            }
            else
            {
                fclose( fp );
                copy_file( filelist[x] );
            }
        }
        return 0;
    }
    You do the rest. Just keep a list of the files, in order, that you need to copy, and try to open one. If it fails, it's on the next cd, so prompt for it and try again.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    Does your example mean that "Install.exe" will reside on say the first cd?
    The world is waiting. I must leave you now.

  4. #4
    ggs
    ggs is offline
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    something as simple as an install program would be resident in memory. just load up all the data you might need from files before you start running, and then you're set.
    .sect signature

  5. #5
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    I'm set, thanks for the replies.
    The world is waiting. I must leave you now.

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,641
    A program cannot delete itself, because a file(the program) is running and you cannot delete a file in use! However, if you install a program, you can add to the end of THAT program "remove(install_file_name);"
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

Popular pages Recent additions subscribe to a feed

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