Hi all!

Hope you well!

I have an application, most of it done and all fanx to the good guys and daniweb! :)

I am curently using the setup project in VS2008 to create an installer for the application.

In my code on I have the following:

  public frmMain()
    {
        InitializeComponent();

         RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
        rkApp.SetValue("MyAppi", Application.ExecutablePath.ToString());       
    }

what I am trying to do is when the user install the application it writes to the registry so that on start up the application will start. Now I am testing the dang thing on Windows 7 - and well the only way I can get it to work is to open the file where the application was saved to (eg Program Files) double click the appliocation and then presto it works.

But knowing a user a bit - they wouldnt like i suppose.

So my question is what is a better more user friendly way to go about this?

Fanx everyone!

Go well and happy coding :)!

Recommended Answers

All 6 Replies

I use VS2005 but I guess it will be the same.
When you select your setup project in Solution Explorer a Registry Editor icon is displayed at the top.
If you click this, it opens an editor that allows you to add registry items that are added/removed by your setup project.
Just add the keys and values you need for your app.
Note: The installer will not run your app immediately. The auto run will only happen on the next re-boot.

I use VS2005 but I guess it will be the same.
When you select your setup project in Solution Explorer a Registry Editor icon is displayed at the top.
If you click this, it opens an editor that allows you to add registry items that are added/removed by your setup project.
Just add the keys and values you need for your app.
Note: The installer will not run your app immediately. The auto run will only happen on the next re-boot.

Hey Nick

How's it going - fanx for the reply.

Just a question - I get the icon and the registry editor, however on the node to I access the HKEY_CURRENT_USER? If I do it nodes down to 'Software' - do I add key and values in the 'Software' node ? Sorry I am a newbie at C# so apologies for silly questions.

Fanx :)

Yes, for each key you need a node in the left hand tree.
E.g.
HKEY_CURRENT_USER
| SOFTWARE
| Microsoft
| Windows
| CurrentVersion
| Run

Then add a new string value in the right hand window.
MyAppi - ""[TARGETDIR]MyAppi.exe""

Notice I surrounded the path with " to allow for spaces in the path.
[TARGETDIR] is an installer property that contains the path to the final install folder.

Note: If you use HKEY_CURRENT_USER then your app will only execute on login for the user that installs your app.

Nick

Yes, for each key you need a node in the left hand tree.
E.g.
HKEY_CURRENT_USER
| SOFTWARE
| Microsoft
| Windows
| CurrentVersion
| Run

Then add a new string value in the right hand window.
MyAppi - ""[TARGETDIR]MyAppi.exe""

Notice I surrounded the path with " to allow for spaces in the path.
[TARGETDIR] is an installer property that contains the path to the final install folder.

Note: If you use HKEY_CURRENT_USER then your app will only execute on login for the user that installs your app.

Nick

hey NIck

Fanx man!

Quick question - that [TAGERDIR] - would that also point to the actually directy / file that the user inputs on the installation wizard as to where the file/application should be saved to?

What I mean is the wizard ask the user if he would like to save to a particular path (eg c:\Program Files\Application Folder) would the TARGETDIR point to the aforementioned folder?

Go well and happy coding :)

Yes, [TARGETDIR] defaults to the installation folder configured in the setup file and will change if the user selects a different location when the setup wizard is run.

commented: cool and helpful ! +1

Yes, [TARGETDIR] defaults to the installation folder configured in the setup file and will change if the user selects a different location when the setup wizard is run.

Thanks Nick you the man! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.