Click here to Skip to main content
11,930,217 members (46,312 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# setup
I'm a beginner. I have recently developed an application in C#. Now I wanna develop its setup. I would like to change programmatically the Default Location of the program, I mean that I would like to set the default location to the location of a program previously installed on the client machine. However I don't know what is the installation path of this other program, so I have to find it programmatically in the registry with a custom action, but I'm not able to launch a custom action before the Installation dir has been already set to the default one.

Is there someone that could help me?
Posted 18-Jun-13 6:37am
Sergey Alexandrovich Kryukov 18-Jun-13 12:14pm
What are you using for the setup project?
Member 9714971 19-Jun-13 3:13am
I'm using Visual Studio 2008
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The ideal way to find a program's installation path is to read it from the registry.Installers usually create a registry key for programs that contains their installation path.

To find if the program has a key in the registry, open "regedit.exe" and use the Edit , after that Find option to try and locate a key with the program name. If such a key exists, you can read it using the RegistryKey class in the .NET Framework library.

If the program does not have a registry key then another option is just to ask the user to locate the .exe file with the OpenFileDialog, although this is obviously not ideal.

Hope that will help, Please mark as answer.
Member 9714971 19-Jun-13 3:18am
Thank you for the information. I know that I can retrieve the installation path from the registry and that is the way I use in the custom action, by the RegistryKey class, to find the path of the other program. However I'm not able to launch the custom action before the Installation Folder form has been shown. What I would like to do is:
- find the path of the other program using the RegistryKey class
- set the path found as Default Location of my program
- install it

I hope that now it is more clear.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hope this thread will solve the custom action problem you are facing

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 19 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100