Skip to content
⌘ NSIS Forum Archive

ExecShell

7 posts

Sky1234#

ExecShell

Am quite new to nsis just having a little problem getting the syntax correct for execshell - if someone could take a quick look would be awesome

I basically need to run 7za as admin so that it can extract an archive in the $EXEDIR to programfiles (The archive is super-large [>4gb] so i cant just bundle it with installer - unless i used torrentdownloader or something)

ExecShell "open" "7za.exe x $EXEDIR\Archieve.7z -pSECRETKEY -aoa -o$INSTDIR'" [[SW_SHOWMAXIMIZED]]

Obviously i replaced the password and archive name. Should be easy to fix - I got nsExec::Exec working but it wont work in program files as it needs to spawn 7za with admin rights.

Am just not sure where/how to use runas to run it as admin
Many thanks
Anders#
ExecShell "runas" "c:\path\to\app.exe" 'param1 "space param" param3'
but I would not recommend doing this:
  1. The runas verb is broken if UAC is turned off
  2. If you require elevation the whole installer should be elevated (RequestExecutionLevel)
Sky1234#
I have a requestexecutionlevel: admin flag in there but the child 7za process it spawns doesnt get admin privilidges and so cant unzip to C:/programfiles from $EXEDIR - If you have a workaround please tell 🙂.
Anders#
Even if you use nsexec? Can you verify all of this by using Process Explorer (Enable the integrity column) and check both your installer and the child process...
Sky1234#
Using NSExec the archive extracts from $EXEDIR to $INSTALLDIR whenever its outside Program Files, as soon as It tries to extract to program files it fails.
aerDNA#
I notice that 7za.exe is the standard choice for dealing with pass-protected archives. I just wanted to share an alternative: 7-zip32.dll. Unlike Pavlov's 7za.dll/7zxa.dll, this one can be employed in NSIS. It's Japanese with poorly translated documentation so here's a snippet that might save someone's valuable time:

File /oname=$PLUGINSDIR\7-zip32.dll 7-zip32.dll
System::Call "$PLUGINSDIR\7-zip32::SevenZip(i 0, t 'x $\"$Archive$\" -o$\"$Destination$\" -p$Pass -y -hide', i 0, i 0) i.R0"
StrCmp $R0 0 Success