moredip
9th September 2003 19:01 UTC
abort when File skipped
Hi all,
So I only just started scripting with NSIS, so apologies in advance for dumb questions...
I think I'm missing something really obvious here, but I've looked in the docs, FAQ, etc. to no avail.
run my script (included below) and some of the files can't be installed due to inadequate admin permissions. So far so good. But NSIS doesn't abort the installation, it just skips the files and continues. I can't work out how to tell NSIS that the files are essential to the install, so it should abort if they fail to install.
Any ideas?
TIA,
Pete
[edited by kichik]please attach large scripts next time. attached below :down:[/edit]
kichik
9th September 2003 19:19 UTC
NSIS sets the error flag if a file was skipped. To check that you need to use ClearErrors and IfErrors. But since you're using /r it will only check after all files are copied. If you know it will always fail if the user is not admin, why don't you check for it using UserInfo?
moredip
9th September 2003 19:48 UTC
So the best I can do is something like the following:
<---------SNIP----------->
Section "Install"
;Install Files
SetCompress off
SetOverwrite Try
; A_Program Files
File /r "C:\4DCInstaller\bin"
IfErrors FileError
; C_Config Files
File /r "C:\4DCInstaller\config"
IfErrors FileError
; G_Imaging DLLs
SetOutPath $SYSDIR
File /r C:\4DCInstaller\img_dll\*.dll"
IfErrors FileError
;...
;...
Goto FileEnd
FileError:
DetailPrint "Could not install some files"
SetDetailsView show
MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST "Could not install some files"
Abort
FileEnd:
SectionEnd
kichik
9th September 2003 19:52 UTC
No, I think the best you can do is check for administrator privileges if you know it needs admin. The next best thing would be generating the File commands using another installer (very simple to make using FileOpen, FileWrite, FileClose, FindFirst, FindNext and FindClose) or another program, call it using !system and !include its output.
moredip
9th September 2003 20:05 UTC
I agree with you about checking for admin rights (I'm playing around with that right now), but I still want something to handle failures to some extent, even if that just means letting the user know.
I don't think it's worth writing another binary and using !system etc. in my case, I think what I've got should be OK, at least for the moment.
BTW, is it possible for File to fail if the user has admin rights? The only thing I can think of is invalid filenames.
Cheers,
Pete
kichik
9th September 2003 20:09 UTC
It can fail if the file is in use. In this case it will just skip the file because you've used SetOverwrite try. If you use SetOverwrite on it will ask the user what to do. You can also deny the user of the option to ignore and force him to abort or retry (latest CVS version - AllowSkipFiles).
moredip
9th September 2003 21:18 UTC
OK.
Thanks for the help kichik :) I've got the admin check code working now, so I'm all set to start trying to figure out why my fsckin' app won't start in win98 :igor:
Cheers,
Pete