Archive: Error with RMDir


Error with RMDir
I would like to report a error with the command RMDir /r or RMDir /rebootok

I have some lines in my scipt that require the script to create a dir place some files into it, execute those files and then delete the dir using RMDir /r

Now the the is the last good build I have of NSIS is from 6th June 2004, with this build the dir's are deleted so I'm not sure when this error has come about.

I have tried it with the /rebootok command, my pc rebooted but the dir's remained

I downloaded the lasted build dated Thu, 26 Aug 2004, 22:50:12 GMT but this made no differance, still the dir's did not delete.

So I tried the new 2.01 rc1, I had the same result the dir's didn't delete but after reinstalling the build from 6th June 2004 everthing was fine and the dir's where deleted.

I'm sorry I can't be more specific with the dates.

I've just looked through the change log and it seems some updates to the RMDIR where made on the

2004-08-06 17:03 Amir Szekely (kichik)

Docs/src/basic.but, Source/exehead/Main.c, Source/exehead/exec.c, Source/exehead/fileform.h, Source/exehead/util.c, Source/exehead/util.h, Source/script.cpp, Source/tokens.cpp: converted RMDir back from SHFileOperation to the good old manual method
- RMDir can now be used with both /r and /REBOOTOK
- RMDir /r no longer leaves lots of files behind if one file removal failed
- The plug-ins directory is now always deleted, if not immediately, then after reboot
- RMDir /r prints a detailed log of its actions


So its just a guess that it might have happened with this update.

Hope this can be sorted out

Thanks

Tony


Are you creating the directories using SetOutPath? If so, you must use SetOutPath again to another directory before deleting it. The current working directory can not be deleted. I guess SHFileOperation, which was used before, had a little workaround for it.

If this is not the case, attach a minimal working example so I can reproduce the problem.


First I'm creating the dir or diectories as there is one inside the other due to the way it works
Then SetOutPath to install the files
SetOutPath "$INSTDIR\Patch"
File "Text1.txt"
File "text2.txt"

and so on
then I use
nsExec::Exec '"$INSTDIR\Patch\install.bat"'

Yes I know I'm using a batch file and most of the time NSIS can do this, but I prefer my way as I couldn't find a script that I wanted

and then I use
RMDir /r "$INSTDIR\Patch"

The basic script looks like this

CreateDirectory "$INSTDIR\Patch"
CreateDirectory "$INSTDIR\Patch\PatchFiles"
SetFileAttributes "$INSTDIR\Patch" HIDDEN
SetOutPath "$INSTDIR\Patch"
File "Patch\install.bat"
SetOutPath "$INSTDIR\Patch\PatchFiles"
File "Patch\PatchFiles\txt.1"
File "Patch\PatchFiles\txt.2"
File "Patch\PatchFiles\txt.3"
File "Patch\PatchFiles\txt.4"
File "Patch\PatchFiles\txt.5"
File "Patch\PatchFiles\txt.6"
File "Patch\PatchFiles\data.1"
File "Patch\PatchFiles\XXXX.exe"
File "Patch\PatchFiles\XXX.exe"
nsExec::Exec '"$INSTDIR\Patch\install.bat"'
RMDir /r "$INSTDIR\Patch"


The Batch file does the rest and works perfectly in milliseconds, one thing I did notice is that all the files that where in the directories where deleted, but not the directories themselves, but there is no command in the above script to delete those files.

Like I said with the older NSIS version the directories where deleted.

You will probably suggest that I use a temp directory to place the files in but then the batch file won't work correctly. Basically the script creates a temp directory within the desired install path, (I must say there are too other executable files installed also but I can't divulge what they are, just to say they change mulitple lines in text files) sorry but I couldn't find a archive nsis file to do what I want it to do, without creating one myself, which I'm not that advance with scripting to do.

Use SetOutPath again with another directory ($INSTDIR for example) before deleting $INSTDIR\Patch.


Hmm.. I don't see what you mean

Would you insert it into the script so I can see

thanks Kichik


SetOutPath $INSTDIR
RMDir /r $INSTDIR\Patch


ah ok thanks

I'll try is with the recent NSIS :)

Cheers mate


That worked perfectly thanks again and sorry for reporting a incorrect error :(