Archive: Rename not recursiv?


Rename not recursiv?
Hello guys

I've a strange behaviour...want to save a directory during uninstall the complete $INSTDIR. I thought I could move my directory to $TEMP and I could move it back.

These are my lines:

Rename $INSTDIR\${ApplicationDatabaseDirectory} $TEMP\${ApplicationDatabaseDirectory} (1)

SetOutPath $TEMP${ApplicationDatabaseDirectory} (2)

RMDir /r $INSTDIR
CreateDirectory $INSTDIR

Rename $TEMP\${ApplicationDatabaseDirectory} (3) $INSTDIR\${ApplicationDatabaseDirectory}

SetOutPath $INSTDIR\${ApplicationDatabaseDirectory}


What do I get:

(1)
The ApplicationDatabaseDirectory is moved to $TEMP without any contained files. Why without...?

(2)
Without the move (1) won't happen.

(3)
"Move" of ApplicationDatabaseDirectory happens, but $TEMP${ApplicationDatabaseDirectory} will not deleted. Why?

Thx for any hints
Sally


Try using $PLUGINSDIR instead of $TEMP. Are you sure no files are locked in your folder being moved?

Stu


Thx,

I made a try with $PLUGINSDIR - without success.
Files are not locked.

My 1st general question is: NSIS:Rename does work recursively? It moves all subfolders and contained files per default, right?


Rename just uses the Windows MoveFileEx API I believe. It has always been recursive in my experience.

By the way actually I would not recommend using $TEMP or $PLUGINSDIR for the temporary location. If they are located on another drive to $INSTDIR then it will probably fail. The manual states that it will only move folders on the same drive.

Stu


Also note that using RmDir /r in an uninstaller is extremely dangerous. You should never ever use it. Suppose the user installed to an existing directory (D:\MyApps) instead of to a unique subfolder, you would end up deleting all his files. Or suppose the user added some files to your installation folder, he/she will NOT expect you to delete those files, because they don't belong to your installation. Or, even worse: suppose that the user moved your uninstall.exe to another folder. Your uninstaller will then delete everything from this new folder, because $instdir == $exedir in the uninstaller!

Instead of just blindly removing stuff, you should only remove what you know you want to remove. So, Delete "$INSTDIR\MyUniqueFilename.ext" for each file.