Skip to content
⌘ NSIS Forum Archive

How to preserve a file if it exists?

3 posts

wrybread#

How to preserve a file if it exists?

I found this recent thread describing how to detect if a file exists:

Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.


That's a part of what I'm trying to do, but I need to check if a file exists (configuration.ini), and if it does, not overwrite it. I'm packing my files like this:

File /r "C:\myfiles\*"

In other words, I'm packing every file in the source directory, including configuration.ini. What I don't understand is how to skip overwriting configuration.ini on the target computer if the file is present there.

Does anything occur to anyone?
redxii#
Re: How to preserve a file if it exists?

Here is one method:


File /r /x configuration.ini "C:\myfiles\*"

SetOverwrite off
File "C:\myfiles\configuration.ini"
SetOverwrite on
This excludes configuration.ini so you can single it out with SetOverwrite.