Archive: Remane aka Win32 API MoveFile


Remane aka Win32 API MoveFile
This is my test script:

OutFile "C:\Documents and Settings\Administrator\Desktop\test\RenameTest.exe"

InstallDir "C:\Documents and Settings\Administrator\Desktop\test"

Section "Rename Test"
Rename "$INSTDIR\source" "$INSTDIR\dest"
SectionEnd
I have in the folder "test" 2 other folders "dest" and "source". In the "source" folder I have a txt file "testfile.txt". What I would like to get at here is to get the installer to move the contence of folder "source" to folder "dest".

From the docu:
Rename source_file to dest_file. Functions just like the Win32 API MoveFile, which means you can move a file from anywhere on the system to anywhere else, and you can [B]move a directory8/B] to somewhere else on the same drive
But I just can't get it to move the damn Dir from point A to B. Any and all help is appriciated :)

Did you try to call MoveFile? Maybe it doesn't move content when the directory already exists.


What do you mean with "call MoveFile"?


The MoveFile Win32 API (http://msdn.microsoft.com/library/de...e/movefile.asp).

Probably it doesn't move content when the directory already exists. You can use CopyFiles to copy the content and then delete the old folder.


Hmm, I see your point, but the MSDN says

MoveFile

The MoveFile function moves an existing file or a directory, including its children.

To specify how to move the file, use the MoveFileEx function.
With "Children" I think it also means Dir's which holds files and subDir's, don't you? Maybe it's a bug in NSIS?

It's doesn't say that it moves the content when the destination directory already exists, only that it can move a directory.


True.. I guess I have to use CopyFiles and RMDir.

Btw: Do you know how I can make the installer check if there is a previus install and if, then ask if the user want to uninstall it or quit?


You have to check for registry keys or files. You can use messageboxes or custom pages to get input from the user.


oki thx m8..