find the installation directory set by user

I am creating a c# app installation program using the VS .Net setup wizzard. The installation program allows the user to customize the installation directory as is usually done. is there a way I can capture the installation directory chosen during the installation process to store in the registry for later retrieval?

Thanks

Bruce
bhomassAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mohammed NasmanSoftware DeveloperCommented:
Hello

   Why you don't return the directory of your application when it's run?, this will work even if the user copy your exe to another place

use
      MessageBox.Show(Application.StartupPath.ToString());
      MessageBox.Show(System.AppDomain.CurrentDomain.BaseDirectory.ToString());

to return the path of your running application, you can get it then store it wherever
HTH


Regards,

                  
0
bhomassAuthor Commented:
Hi mnasman

same answer as in my other thread. it is because I need this for an Excel add-in dll. the two calles you suggested will return path for Excel.exe, not my add-in.

Bruce
0
Mohammed NasmanSoftware DeveloperCommented:
then use
     MessageBox.Show(Application.ExecutablePath.ToString());
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

bhomassAuthor Commented:
I have already determined that System.Reflection.Assembly.GetExecutingAssembly().Location.ToString() is the one that can give me the right path at run time.

I am leaving this question open to see if anyone can tell me how to find the user designated installation directory from the setup wizzard. I believe this can be done because there are many apps on my system which records the installation directory as a registry entry under HKEY_currentuser/software.

Bruce
0
weareuProgrammerCommented:
In your deployment project create a custom installer class (this class will store the value in memory) if you don't feel like reading up on installer classes. Create a normal Console Application to store the path in the registry... The console app takes arguments and the first argument args[0] will contain the path...

Add the primary output of this console application project to your setup project as well.

Now in your deployment project, go to the Custom Actions view (if you are using VS.NET)... Right click "Commit" and add a custom action browse to the place where you specified the primary output of the console application must go defaultly it should be in "Application Folder" Select the primary output of this console application. A new custom action should be added under commit. Now right click the custom action and click properties. In the properties window there should be the "InstallerClass" property. Since this is not a Installer Class, set it to false or your setup will fail. In the Arguments property type the following: "[TARGETDIR]" with the quotes otherwise your first argument will end after the first space encountered so it will return something like c:\program where with the quotes it will return the whole path...

The [TARGETDIR] variable holds the destination path in MSI...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
weareuProgrammerCommented:
For more detailed instructions, please specify where help is needed...
0
bhomassAuthor Commented:
wonderful. Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.