Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Shelling WINRAR  (Read 4967 times)

0 Members and 1 Guest are viewing this topic.

RFB

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Unknown
    Shelling WINRAR
    « on: November 08, 2020, 11:43:09 AM »
    Hello,

    Using the WINRAR GUI I can create a Self Extracting Zip file that executes a program after the file extraction. However, I want to do it inside of a program that I writing. Using Shell I can create the SFX with the desired behavior with the exception that it doesn't execute the specified program after file extraction.

    Shell "cmd.exe /c c:\progra~1\winrar\rar.exe a -ibck -m5 -setup=setup.wsf -sfx Setup.exe"

    a -- add all files to archive
    -ibck -- run in background
    -m5 -- Best compression
    -setup=setup.wsf -- program to execute after file extraction
    -sfx -- instruction to create self extracting zip file named Setup.exe

    I have been told that I need to specify the path in the command but that isn't required because the path is known. Proof of that is that the Self Extracting executable file, Setup.exe found the proper folder. However, I specified the path with the -ap switch and it made no difference other than it created the chain of folders on extraction. I have been all over this like it was my first girlfriend and I'm stumped.

    Ron

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Shelling WINRAR
    « Reply #1 on: November 08, 2020, 04:38:44 PM »
    I don't quite understand how the "path is known". you are telling rar.exe to add all files to the archive, run in the background, use the best compression, to execute a particular file when extracted, and to create a self-extracting file, but you never specify what files or folders it should include- it literally isn't known, so it's going to add all the files in your programs' current working directory (inherited by the child process) to the archive.

    The ap switch sets the path inside the archive that the files will be added. To change what files are added, You need to specify source files as their own argument, either a set of directories or a set of filenames.

    Code: [Select]
    Shell "cmd.exe /c c:\progra~1\winrar\rar.exe a -ibck -m5 -setup=setup.wsf -sfx Setup.exe <path to the files/directory you want in the archive>"
    I was trying to dereference Null Pointers before it was cool.