Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Create self extract exe setup file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gafny Jacob
    replied
    you can use it for free

    ------------------

    Leave a comment:


  • Colin Schmidt
    replied
    Nice Job Clean, small, and simple: the way I like it.

    What rights do you reserve on the copyright? Is this little app freeware or shareware if it has a copyright notice in your name?

    Thanks,
    Colin Schmidt

    ------------------
    Colin Schmidt & James Duffy, Praxis Enterprises, Canada

    Leave a comment:


  • Gafny Jacob
    started a topic Create self extract exe setup file

    Create self extract exe setup file

    Code:
    '****************************************************************************
    '*   SelfExe - Pack & Unpack Setup files to One self extract,               *
    '*             self activated file.                                         *
    '*                                                                          *
    '*             CopyRight (C) Gafny Jacob 1998                               *
    '*                                                                          *
    '*   This Little program intend to pack all setup files                     *
    '*   Into one self extracting file, Since setup files are already           *
    '*   compress, the use of zip or arj program has insignificant effect,      *
    '*   The benefit of this program is that it allow you to immediatly run     *
    '*   the setup program. it is intend mainly to pack setup file into         *
    '*   One file for internet downloads.                                       *
    '*   In order to produce setup file one should take the following steps     *
    '*   1 - Compile this code with PbDll 6.0                                  *
    '*   2 - Prepare your setup files & place them in separate directory        *
    '*   3 - Copy the compiled program (Selfexe.exe) to that directory          *
    '*   4 - Run the program with /s switch (SelfExe /s)                        *
    '*       The result is a file name GSetUp.exe, this file is self extracting  *
    '*       File, running this file (GSetUp.exe) will extract all setup file    *
    '*       And will run the Setup Program (Assuming the setup program name is *
    '*       SetUp.Exe)                                                         *
    '*                                                                          *
    '****************************************************************************
    
    $COMPILE EXE
    $DIM ALL
    
    GLOBAL Sign AS STRING
    GLOBAL MyName AS STRING
    
     
    SUB PackFiles ()               ' File packing routin
        DIM DestFile AS STRING
        DIM Buf AS STRING
        DIM mFile AS STRING
        DIM Remain AS LONG
        DIM Cut AS LONG
        DIM nLen AS BYTE
        DestFile = "GSetUp.EXE"                    'This File is  New created file (selfextract_
        IF DIR$(DestFile) <> "" THEN KILL DestFile
        OPEN DestFile FOR BINARY SHARED AS #1
        OPEN MyName FOR BINARY SHARED AS #2
        Buf = SPACE$(LOF(2))
        GET #2,, BUF
        CLOSE #2
        PUT #1,, BUF                                'Copy myself into target file
        PUT #1,, Sign                               'Now put sign to mark end of exe file
        Mfile = DIR$("*.*")
        WHILE mFile <> ""                           'Start to read all file in directory
          IF (UCASE$(mFile) <> UCASE$(MyName)) AND (UCASE$(mFile) <> "GSETUP.EXE") THEN
              nLen = LEN(mFile)
              PUT #1,, nLen                         'Write the length of file name
              PUT #1,, mFile                        'Write the name of the file
              OPEN mFile FOR BINARY SHARED AS #2
              Remain =LOF(2)                        'Get size of the file
              IF Remain THEN
                 PUT #1,, Remain                    'Write it to target file
                 DO WHILE Remain
                    IF Remain > 32750 THEN
                       Cut = 32750
                    ELSE
                       Cut = Remain
                    END IF
                    Remain = Remain - Cut
                    Buf = SPACE$(Cut)
                    GET #2,, Buf                   'Now add the file to destination
                    PUT #1,, Buf
                 LOOP
              END IF
              CLOSE #2
          END IF
          mFile = DIR$
        WEND
        CLOSE
    END SUB
    
    SUB UnPackFiles ()                'File extraction routin
    
        DIM SourceFile AS STRING
        DIM Buf AS STRING
        DIM MyEof AS LONG
        DIM Remain AS LONG
        DIM Cut AS LONG
        DIM nLen AS BYTE
        DIM mFile AS STRING
        SourceFile = "GSetUp.EXE"
        OPEN SourceFile FOR BINARY SHARED AS #1    'Open the file
        IF LOF (1) < 15000 THEN CLOSE: EXIT SUB    'File too small - must be error
        Buf = SPACE$(15000)                        'Get all original exe file into buffer
        GET #1,, Buf
        MyEof = INSTR(Buf, Sign)                   'Look for signatur in the exe file
        IF MyEof = 0 THEN EXIT SUB
        MyEof = INSTR(MyEof + 1, Buf, Sign)        'Now look For signatur for eof
        IF MyEof = 0 THEN EXIT SUB
        Buf = LEFT$(Buf, MyEof)                    'MyEof now is size of original exe
        OPEN "SelfExe.Exe" FOR BINARY SHARED AS #2
        PUT #2,, Buf
        CLOSE #2                                   'Make Reproduction of original exe
        MyEof = MyEof + LEN(Sign)
        WHILE MyEof < LOF(1)                       ' Now start to exetract all files
           GET #1, MyEof, nLen                     'Read file name length
           INCR MyEof
           mFile = SPACE$(nLen)                     'Read the file name
           GET #1,MyEof, mFile
           MyEof = MyEof + nLen
           GET #1, MyEof ,Remain                    'read the file size
           MyEof = MyEof + 4
           OPEN mFile FOR BINARY SHARED AS #2
           WHILE ReMain
              IF Remain > 32750 THEN
                Cut = 32750
              ELSE
                Cut = Remain
              END IF
              Remain = Remain - Cut
              Buf = SPACE$(Cut)
              GET #1, MyEof, Buf                   'extract the file
              PUT #2,, Buf
              MyEof = MyEof + Cut
           WEND
           CLOSE #2
        WEND
        Cut = SHELL ("SetUp.Exe", 1)              'All done - invoke setup.exe
    END SUB
    
    FUNCTION WINMAIN (BYVAL CurInst AS LONG, _
                      BYVAL PrvInst AS LONG, _
                      CmdLine AS ASCIIZ PTR, _
                      BYVAL CmdShow AS LONG) EXPORT AS LONG
                      
         Sign = "MyEndOfFileSignature"
         MyName = "SelfExe.Exe"
    
         IF INSTR(UCASE$(COMMAND$), "/S") THEN
            PackFiles
         ELSE
            UnPackFiles
        END IF
    END FUNCTION
Working...
X