How can exe that runs after setup know the setup destination folder?

ppsa

Member
Joined
Sep 28, 2008
Messages
13
Programming Experience
10+
I have a solution with 3 projects: 1) a vb.net windows forms app (main app), 2) a setup project to install that app, and 3) another vb.net win forms app that is built into an exe that runs at the end of the setup program (I'll call this the post-setup exe). The post-setup exe will get the location of a file from a user and then copy that file to the same destination folder into which the setup program just finished installing the main app. How can I access that destination folder from inside the post-setup exe? Thanks!
 
Exactly what type of project is the installer? Generally you would have that installer invoke that post-install tool and it would pass in the path if required. Exactly how that would be done would depend on the installer but, regardless, the tool itself would have to receive the path as a commandline argument.
 
Or the tool could use Application.StartupPath if WinForms app or if it's a console app you have System.AppDomain.CurrentDomain.BaseDirectory that would work, or if you want to have 1 way of doing this regardless of project type you have IO.Path.GetDirectoryName(Diagnostics.Process.GetCurrentProcess().MainModule.FileName) to know where it is installed to, then the installer would just need to invoke it and it would already know where it is.
 
The installer is built in to VS 2010. I resolved this by passing [TARGETDIR] to the custom action in the Setup project (primary output of the 3rd project as mentioned above). I then looked at the Environment.GetCommandLineArgs() to access the passed value in the exe.

Thanks all for your help.
 
Back
Top