- NSIS Discussion
- Error when Extracting NSIS-Compressed Files
Archive: Error when Extracting NSIS-Compressed Files
rpgfan
29th August 2004 23:17 UTC
Error when Extracting NSIS-Compressed Files
I am trying to use NSIS to distribute a mod that I made. Everything compiles properly, but whenever I test the installer, I get the following error from the installer that was made by NSIS v2.0.
Error opening file for writing:
If I click "Ignore", I get the same message for the next file in the archive.
The error persists whether the original files are present in the installation directory or not, so it is not an overwriting issue.
Any ideas that may help?
scully13
30th August 2004 16:42 UTC
Make sure that if the file already exists it isn't in use or read-only. If that isn't it make sure you have enough free disk space. That's the only time I've run into that error message but I guess there could be other reasons.
rpgfan
31st August 2004 02:43 UTC
The file is neither in use, nor is it Read Only.
I've got more than 25GB available on my hard drive, so it is not a problem with that.
I am not having problems extracting files that are in the root directory, only those that were in a folder during compression. Do all the files need to be in the same location prior to compiling the install script to get things to work correctly?
KrYpT
31st August 2004 05:19 UTC
(A side note... I doubt compression's your problem.)
I don't know if this matters, but it's possible you're not creating the folders before you fill them with files. Maybe it would help to use CreateDirectory?
Is the path given by the error prompt accurate? I know I was confused the first time I tried the command "File Sounds\Ding.wav" and it ended up $OUTDIR instead of $OUTDIR\Sounds. Again, check if the folder exists.
Hope that helps....
Geoff
scully13
31st August 2004 13:08 UTC
All the files don't need to be in the same location prior to compiling the script. You'll be specifying a path in your File command where the file is coming from. Do something like what KrYpT said and use CreateDiretory or use SetOutPath like it is below to make sure the folder exists and to set the path it should go to. If that doesn't work put some message boxes in to show you what your $OUTDIR and/or $INSTDIR variable are before doing your copy.
SetOutPath "$INSTDIR\help"
File F:\companies\help\*.htm
SetOutPath "$INSTDIR\help\images"
File F:\companies\help\images\*.gif
rpgfan
31st August 2004 17:39 UTC
I don't know if this matters, but it's possible you're not creating the folders before you fill them with files. Maybe it would help to use CreateDirectory?
The folders do exist on my machine prior to putting files there.
Is the path given by the error prompt accurate? I know I was confused the first time I tried the command "File Sounds\Ding.wav" and it ended up $OUTDIR instead of $OUTDIR\Sounds. Again, check if the folder exists.
The path given by the error prompt is correct.
All the files don't need to be in the same location prior to compiling the script. You'll be specifying a path in your File command where the file is coming from. Do something like what KrYpT said and use CreateDiretory or use SetOutPath like it is below to make sure the folder exists and to set the path it should go to. If that doesn't work put some message boxes in to show you what your $OUTDIR and/or $INSTDIR variable are before doing your copy.
SetOutPath "$INSTDIR\help"
File F:\companies\help\*.htm
SetOutPath "$INSTDIR\help\images"
File F:\companies\help\images\*.gif
No help there. Here's the complete script that I'm compiling. Maybe that will help.
scully13
31st August 2004 18:57 UTC
It worked fine for me. I don't have that game installed so that key doesn't exist in my registry. I changed it to something else though and created a bunch of empty files to match your file names and it was fine. You said the error message is returning the correct path or is it just saying "\Kitanya\something.cre". In this case here it doesn't have an $INSTDIR set.
scully13
31st August 2004 19:03 UTC
It looks like your InstallDirRegKey is wrong. It's not pointing to anything under BG2Main.exe. It should be something more like:
InstallDirRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\BG2Main.exe" Path
I'm guessing on the "Path" part since I don't have the game but I have several other apps installed that use a similar deal in the registry. Try:
MessageBox MB_OK $INSTDIR
before your first SetOutPath.
rpgfan
31st August 2004 21:25 UTC
That worked. It is extracting everything correctly now.
However, I'm getting a problem with that "ExecWait" in the .onInstSuccess call-back function. Namely, the executable won't work. I get a "bad filename" or somesuch error, despite the fact that the file is both named identically to the one in the script and it is contained in the script to be compressed into the archive.
scully13
31st August 2004 21:35 UTC
I put a dummy EXE file in place of setup-kitanya.exe and it executed just fine for me. It ran as soon as I clicked Close on the final install dialog. Does the real setup-kitanya.exe reguire some command line parameters or something. I'm guessing that maybe you changed some other stuff in your script after you posted one here and it caused a problem. If so put your script back up here as an attachment and I'll check it out again.
rpgfan
1st September 2004 02:08 UTC
setup-kitanya.exe does not require command line parameters.
I can't see exactly what the error given is, as my computer opens and closes the DOS window too quickly.
scully13
1st September 2004 14:21 UTC
Ok, so the script is basically the same as it was before. I was thinking maybe you added some new stuff that might have altered the $INSTDIR before the ExecWait command. Both scripts work fine for me with fake files and a dummy EXE that just pops up a dialog. So, my next question is what is the path that you are installing into? I can use that to try and recreate exactly what your doing. Also, You said a DOS box pops up so what type of app is this that is getting launched (MFC app, console program, another installer)?
KrYpT
1st September 2004 18:08 UTC
I don't know if this is the problem or not, but maybe you could try "SetOutPath $INSTDIR" before the ExecWait? That just sets the current directory (so that the setup program is more likely to find associated files).
rpgfan
2nd September 2004 19:58 UTC
So, my next question is what is the path that you are installing into?
On my computer, it is C:\Program Files\Black Isle\BGII - SoA
Also, You said a DOS box pops up so what type of app is this that is getting launched (MFC app, console program, another installer)?
It's a console program.
I don't know if this is the problem or not, but maybe you could try "SetOutPath $INSTDIR" before the ExecWait? That just sets the current directory (so that the setup program is more likely to find associated files).
I'll try that.
zimsms
2nd September 2004 20:12 UTC
"When executing an application that is a 32-bit GUI application, CMD.EXE does not wait for the application to terminate before returning to the command prompt. This new behavior does NOT occur if executing within a command script."
You need to create a small C app that monitors the thread of the process you are running. If you don't know C, then do the following:
1. Get the Windows Platform SDK. The C# compiler comes with it.
2. Compile the source found in this thread.
then call the new executable using your app as the -f parameter, as specified in the syntax I posted in the above thread.
KrYpT
2nd September 2004 20:52 UTC
If it's really a console app you shouldn't need zimsms' code. Try using nsExec::ExecToLog and see what it comes up with.
Also, I think you can get around the problem zimsms was having by creating a batch file which simply runs your exe. Haven't tested this but you should get the idea:
ExecWait "echo setup-kitanya.exe > temp.bat"
ExecWait "temp.bat"
Delete "temp.bat"
rpgfan
2nd September 2004 23:18 UTC
Actually, trying to run it via a batch file was one of the first things that I tried. I got the same result.
I'll try using ExecToLog and see if that tells me exactly what the error is.
scully13
3rd September 2004 13:11 UTC
What were the results of using SetOutPath $INSTDIR to modify the $OUTDIR that KrYpT suggested? I'm assuming that after you do your install you are able to run the setup-kitanya.exe from the installed directory and it works fine. So, I'm thinking that should be all you need.
zimsms
3rd September 2004 13:51 UTC
As my previous post stated if the executable you are attempting to run was actually compiled as a 32-bit GUI app, then there are only the two ways around it. a) Using the ExecWait function I created, or b) Use thw Windows Scripting Wizard to create a script equivelant to the batch file you want to use.
rpgfan
3rd September 2004 14:04 UTC
Originally posted by scully13
What were the results of using SetOutPath $INSTDIR to modify the $OUTDIR that KrYpT suggested? I'm assuming that after you do your install you are able to run the setup-kitanya.exe from the installed directory and it works fine. So, I'm thinking that should be all you need.
It now works perfectly.
Thanks for the help, guys.