Groups | Blog | Home
all groups > visual studio .net setup > april 2004 >

visual studio .net setup : Prevent Windows Installer from overwriting data files currently on the user's machine.


daniel.benjamin NO[at]SPAM epa.gov
4/16/2004 12:51:00 PM
I have created a windows installer program that places certain
supporting files in directories that may already exist on the user's
machine. If that file (example.txt) already exists on the user's
machine, I do not want the installer to overwrite that file. If that
file not only exists but also is newer than the file from the
installer, leaving the file on disk would be an even better solution.

There is probably a simple way to do this. I tried to create a
condition for that file but Windows Installer would not let me. How
do I get around this?

Thanks,

Ben Daniel
CSC
willbu NO[at]SPAM online.com (
4/19/2004 10:30:07 PM
Daniel,

What you are asking for is kind of simple. If you used the Visual Studio
Installer or VS.NET to create the MSI package you won't be able to
accomplish what you're after from in there. You'll need to open the MSI
file using ORCA, which can be obtained by downloading the Windows Installer
SDK from the Microsoft website. You will need to set the AppSearch action
to search for the DLL and set a property based on whether it finds the file
or not.

From the help - "AppSearch Action searches the user's system for file
signatures specified in the AppSearch table. If the AppSearch action finds
an installed file or directory with the specified signature, it sets a
corresponding property, also specified in the AppSearch table, to the
location of the file or directory. When searching for a file, the file
signature must also be listed in the Signature table. If a file signature
is listed in the AppSearch table and is not listed in the Signature table,
the search looks for a directory, registry entry, or .ini file entry."

If you download the Windows Installer SDK, you will find steps on doing
this in the help under the topic called "Searching for Existing
Applications, Files, Registry
Entries or .ini File Entries".

Will Buffington
Microsoft Developer Support

Phil Wilson
4/22/2004 4:41:13 PM
The short answer is that you can't do this at all in a VS setup because
there are no hooks for you to call code (like a custom action) from that
dialog, so you'd need to use Orca to add that to the UI *and* have the
separate DLL containing the custom action.

It seems rather odd to me that you're doing this. The user can choose an
arbritary folder to install into, so you have this odd situation because you
only seem to need this checking code if the user installs into a folder that
might have those files already there. It all seems completely
non-deterministic. What problem are you trying to solve?
--
Phil Wilson [MVP Windows Installer]
----
[quoted text, click to view]
Hi,

I am trying to do something similar. I want to do the following:
1.. Each time the user clicks the Next> button on the Select Installation
Folder (FolderForm) dialog box
1.. Check for the existence of a file being installed by the msi into
the FolderPathEdit directory
2.. If file exists, display a confirmation dialog box with OK/No
controls
1.. User clicks OK --> continue
2.. User clicks No --> go back to FolderForm (do nothing)
3.. Otherwise, continue
Must this code be written in seperate .dll?

Thanks.



[quoted text, click to view]

bhin
4/22/2004 10:59:57 PM
Hi,

I am trying to do something similar. I want to do the following:
1.. Each time the user clicks the Next> button on the Select =
Installation Folder (FolderForm) dialog box
1.. Check for the existence of a file being installed by the msi =
into the FolderPathEdit directory
2.. If file exists, display a confirmation dialog box with OK/No =
controls
1.. User clicks OK --> continue
2.. User clicks No --> go back to FolderForm (do nothing)
3.. Otherwise, continue
Must this code be written in seperate .dll?

Thanks.



[quoted text, click to view]
bhin
4/22/2004 11:58:11 PM
Thanks for responding.

I'm installing an Administrative Template (.adm) file.
I want to warn the user that s/he is about to overwrite an existing file if
a file with the same name is detected in the folder at the time the user
clicks the Next button.

I didn't think you could do it in the IDE. I just wanted to make sure I'm
not missing the easy way to do this, if it exists.

Any better ways to do this?

Thanks.



[quoted text, click to view]

Phil Wilson
4/25/2004 10:44:50 AM
My approach tends to be to keep it simple and minimize the opportunities for
the user to do something wrong. Maybe I'd choose a folder I know will be
unique and just install into there, then there is no chance the user will
overwrite an existing file.
--
Phil Wilson
[MVP Windows Installer]
[quoted text, click to view]

(smurray NO[at]SPAM murraycom.com)
5/2/2004 8:06:45 AM
Ben,

I have a similar situation: My msi file installs an empty database when the user first installs my application. That database is where the user's data is stored as he uses the app.

However, if the user re-installs the app (for whatever reason), the msi file overwrites his existing database with an empty one.

Did you ever find a solution to this?

I've tried to figure out how to set a condition that checks if the file is already there, but I've come up empty.

Thanks,
Scott Murray

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
AddThis Social Bookmark Button