Distributing application

Q

Q

Hello you all,

I have created an application that reads and writes data to a access
database.
To access the database, I use a System DataSource (Connection string:
DSN=MyDataSourceName).

If I distribute my application, there is a possibility to add the registry
key for the system datasource so that the
System DataSource will be created on the machine where the application is
being installed.
The problem here is that the path to the database can be different than the
original path on the developers machine.
(the path depends on the installation folder the user selects!!)
Is there a way to solve this problem???
Can you refer to the application folder in the registry entry?

Any help would be appriciated!

Thanks

Q
 
Q

Q

Yes Phil,

I think you misunderstood the question.
I simply want the setup of my application to do the job, so that the user
who installs the application doesn't
have to worry about the location of the database.

Thanks for the suggestion anyway,

Q
 
S

Sahil Malik

Q,

Yes you can easily acheive this. The more standard way would be to create an
MSI installer. You can then use a class that inherits from
System.Configuration.Install.Installer and write code in C# or VB.NET that
allows you to customize the install process to your heart's content.

My recommendation would be to store stuff in the application.config file
rather than the system registry because for security reasons there's a (good
or bad) push towards letting the average joe user run his machine as a
non-admin, and to qualify for "Runs on Windows XP" label, your app must be
able to run without running as admin - i.e. it cannot access registry.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
Q

Q

Hey Rulin,
Thanks for your reply but:

How can you use "Application.StartupPath" in the setup of the application?

I'm not sure if you understood my problem:

I just want the DataSource to be created in the Registry during the
installation of my application. The problem here is that
the path to the database (which has to be included in the DataSource)
depends on the location where the user installs the
application.
I know that you can create Registry-entries from within the setup of an
application but according to me, this only works
with predefined values. (e.g. you can say that
DBQ=c:\Installation_Directory\Database\Mydatabase.mdb).
The problem here is that the information provided here is not valid if the
user decides to install the application in another directory.
Is there a way to change this value
(c:\installation_directory\database\mydatabase.mdb) to the valid value?

Thanks,

Q
 
J

John C. Kirk

Sahil said:
My recommendation would be to store stuff in the application.config file
rather than the system registry because for security reasons there's a
(good
or bad) push towards letting the average joe user run his machine as a
non-admin, and to qualify for "Runs on Windows XP" label, your app must be
able to run without running as admin - i.e. it cannot access registry.

I don't think that's quite correct. As a non-admin, you are allowed to make
changes that just affect you, but you can't make system wide changes (that
requires admin rights). In particular, you can make changes to the registry
under HKEY_CURRENT_USER (and read from HKEY_LOCAL_MACHINE).

As for the config file, this is always stored in the same folder as the
running application. However, non-admin users can't make any changes under
C:\Program Files (to avoid the problem where a virus gets onto your machine,
and infects every other installed application). So, certainly don't put your
database there (as Rulin Hong suggested). If you know that the database
won't move after the application is installed, then storing the location in
the config file would work.

In a more general case (like the MRU list of databases in Access), the
user's section of the registry would be a good place to store the list. You
can also store user-specific information in their profile, e.g. C:\Documents
and Settings\John\Application Data\<my company>\<my app>

I certainly agree that it's a good idea to develop applications that don't
require admin rights, and I think that the best way to achieve this is for
you (as a developer) not to have admin rights on your machine; keep a
separate login account for times when you need to install software etc. I've
been doing that for the last few months, and it's working well for me.

John
 

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