Search code examples
compressionnsis

What is the best way to compress a text file from within an NSIS script?


Assuming that it is possible to compress a file from within an NSIS script, what is the best way to accomplish that and what would be the actual statement?

Is there a built-in NSIS instruction for that?


Solution

  • Your question does not really make a lot of sense, are you asking how to install a file, or are you trying to use NSIS as some sort of general file compression utility?

    Here is a basic script that "installs" a file:

    Outfile test.exe
    Requestexecutionlevel user
    Setcompressor LZMA
    Page instfiles
    
    Section
    ;Not a good idea to hardcode the destination like this, 
    ;normally you would use a directory page so the user can choose
    SetOutPath "c:\SaveToThisFolder"
    
    ;Take thefile.txt from the system you compile on and output it on the end users system 
    ;into the directory specified by the SetOutPath call
    File "thefile.txt"
    Sectionend
    

    If you are writing an actual installer for some application, you really should take a look at some of the examples that ship with NSIS