How to prevent file from being replaced on startup?

D

DonutMan

I have a setup project that I've created for an application that
requires a temporary data file to be installed in the root
installation directory. On application startup, if this data file
exists in the directory, the application will process the file and
then rename it so that it does not get processed again the next time
the application is run. In this manner, data updates are
accomplished
by simply copying a new data file into the installation directory
instead of having to reinstall the application.

The problem, of course, is that when the application is launched, the
Windows Installer mechanism automatically detects that the data file
is missing and restores the file before actually starting the
application. Does anyone know the best way to prevent this from
occurring? Will this happen if I install the data file to a
different
location instead (e.g., the "My Documents" folder?)


Thanks in advance,
Mike
 
D

DeveloperX

I have a setup project that I've created for an application that
requires a temporary data file to be installed in the root
installation directory. On application startup, if this data file
exists in the directory, the application will process the file and
then rename it so that it does not get processed again the next time
the application is run. In this manner, data updates are
accomplished
by simply copying a new data file into the installation directory
instead of having to reinstall the application.

The problem, of course, is that when the application is launched, the
Windows Installer mechanism automatically detects that the data file
is missing and restores the file before actually starting the
application. Does anyone know the best way to prevent this from
occurring? Will this happen if I install the data file to a
different
location instead (e.g., the "My Documents" folder?)

Thanks in advance,
Mike

How about using two different file names. One for in situ updates and
one on installation. That's probably the easiest way I can think of to
differentiate between the two events.
 
N

Nicholas Paldino [.NET/C# MVP]

Mike,

You are probably better off placing the data in either the Application
Data, the Common Application Data, or the Local Application Data
directories. Each of these is for application data that is shared among
users. You can have your installer place the file in one of those
directories, and then check at startup for the file to update in that
directory.

You can get the path to these directories through the static
GetFolderPath method on the Environment class, passing the
SpecialFolder.ApplicationData, SpecialFolder.CommonApplicationData, or
SpecialFolder.LocalApplicationData enumeration values.
 
P

Phil Wilson

Repair is an integral part of Windows Installer. A design that requires that
it will never happen is unsafe. You can add DISABLEADVTSHORTCUTS to your MSI
file with Orca. That will prevent routine repair via shortcut use, but there
are lots of other things that will do an automatic repair if Windows thinks
your product isn't installed as it should be. Also, you can't stop somebody
right-clicking the MSI file and choosing Repair, and what about Add/Remove
Prrograms "Click Here for Support Information" and the Repair button?
 
D

DonutMan

Thank you everyone for your responses. Unfortunately, installing the
file to the Common Application Data folder made no difference, as it
was still "repaired" as soon as I launched the application. So as
Phil Wilson suggests, I am going to alter the design of the program to
leave the file alone (instead of renaming it), and instead the program
will compare the date/time stamp of the file to a value in the
Registry to determine if the file needs to be processed.

- Mike

Repair is an integral part of Windows Installer. A design that requires that
it will never happen is unsafe. You can add DISABLEADVTSHORTCUTS to your MSIfilewith Orca. That willpreventroutine repair via shortcut use, but there
are lots of other things that will do an automatic repair if Windows thinks
your product isn't installed as it should be. Also, you can't stop somebody
right-clicking the MSIfileand choosing Repair, and what about Add/Remove
Prrograms "Click Here for Support Information" and the Repair button?

--
Phil Wilson
[MVP Windows Installer]




I have a setup project that I've created for an application that
requires a temporary datafileto be installed in the root
installation directory. On application startup, if this datafile
exists in the directory, the application will process thefileand
then rename it so that it does not get processed again the next time
the application is run. In this manner, data updates are
accomplished
by simply copying a new datafileinto the installation directory
instead of having to reinstall the application.
The problem, of course, is that when the application is launched, the
Windows Installer mechanism automatically detects that the datafile
is missing and restores thefilebefore actually starting the
application. Does anyone know the best way topreventthis from
occurring? Will this happen if I install the datafileto a
different
location instead (e.g., the "My Documents" folder?)
Thanks in advance,
Mike- Hide quoted text -

- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top