Extract file from a nsis installer
:confused: I was thinging if there is a way to extract files from a installer created with NSIS.
Maybe using a command line parameter with the installer like:
setup.exe /please_gimme_my_file:app.exe :D
There is ?
Archive: Extract file from a nsis installer
Extract file from a nsis installer
:confused: I was thinging if there is a way to extract files from a installer created with NSIS.
Maybe using a command line parameter with the installer like:
setup.exe /please_gimme_my_file:app.exe :D
There is ?
nsis installers usually have their files compressed in an archive block.. if the compression is lzma, you can extract the files using 7zip.
It's also one of many good reasons for those writing installers to offer an option to just dump the contents from within the installer, and encrypt or obfuscate the files within.
OK Thanks Animaether
But if you know if there is a script that I could put inner the installer script to let me extract a file for a location that I choose using command line parameter if possible.
Or if you have any idea...
Tell me please
Thanks again :D
ohhh you want to actually offer this yourself in your own installer!
Well that's a whole different question :D
Try this...
!include "StrFunc.nsh" ; String library
SetCompressor lzma
Name "Test"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILES\test"
${StrStr}
!macro getParameterValue SWITCH DEFAULT
!define UniqueID ${__LINE__}
Push $0
Push $1
Push $2
Push $3
Push $4
; Find SWITCH in CMDLINE
Push "$CMDLINE"
Push "${SWITCH}"
Call StrStr
Pop $0
; Check if the SWITCH was specified at all
StrCmp "$0" "" gpv_notfound_${UniqueID}
; It was found, so get the actual value
StrLen $2 "$0"
StrLen $1 "${SWITCH}"
StrCpy $0 "$0" $2 $1
; Check if the last character is a doublequote, and remove if it is
StrCpy $3 "$0" 1 -1
StrCmp $3 '"' 0 +3
StrLen $2 "$0"
IntOp $2 $2 - 1
StrCpy $0 "$0" $2 0
; If value is null, assign default value
StrCmp "$0" "" 0 +2
StrCpy $0 "${DEFAULT}"
goto _done_${UniqueID}
gpv_notfound_${UniqueID}:
StrCpy $0 -1
_done_${UniqueID}:
Pop $4
Pop $3
Pop $2
Pop $1
Exch $0
!undef UniqueID
!macroend
Function .onInit
!insertMacro getParameterValue "/extractFile=" "%nofile%"
Pop $0
StrCmp $0 -1 0 +3
MessageBox MB_OK "/extractFile= parameter not specified - skipping"
goto _skip
StrCmp $0 "%nofile%" 0 +3
MessageBox MB_OK "/extractFile= parameter specified, but value empty - skipping"
goto _skip
SetOutPath $EXEDIR
MessageBox MB_OK "File to extract: $0"
StrCmp $0 "test.txt" 0 +4
MessageBox MB_OK "Extracting file: $0"
File "test.txt"
Abort
StrCmp $0 "test2.txt" 0 +4
MessageBox MB_OK "Extracting file: $0"
File "test2.txt"
Abort
MessageBox MB_OK "Invalid file specified - aborting."
Abort
_skip:
MessageBox MB_OK "Continuing to GUI mode."
FunctionEnd
Section "MainSection" SEC01
; dummy section
SectionEnd