Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

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
0
bhomass
Asked:
bhomass
  • 3
  • 2
  • 2
1 Solution
 
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
weareuCommented:
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
 
weareuCommented:
For more detailed instructions, please specify where help is needed...
0
 
bhomassAuthor Commented:
wonderful. Thanks
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now