tags:

views:

801

answers:

5

I have created a own installer for my application(c#). During the installation process, i will ask the end-user for the install location. My problem is how to pass that install location(user input) to the installer. The installer always trying to install at c:\progam files[mfr name][product name].

please help me

+2  A: 

The installer will ask for the install location, and put it in a installer variable called %TARGETDIR%. You can supply this as a custom argument to your custom actions so they can use it to perform other duties.

Goto the custom actions viewer, and select the properties for your custom action.

Enter the following as the CustomActionData parameter:

/TARGETDIR="[TARGETDIR]\"

Then in your custom action's code, you can access this property by using something like this:

string targetDir = Context.Parameters["TARGETDIR"];

(Thanks to Tafa for inspiration to improve my answer).

Neil Barnwell
Thanks, I will try this.
A: 

How can i use this custom action property by code?

A: 

In case it is not just the target directory needed but some other value determined during setup, CustomActionData is the way to go. Then, an Installer should be used to reach that value. For example;

this.Context.Parameters["targ"];

in installer code, will get the value of CustomActionData /targ="someValue"

tafa
A: 

Assuming you've created the installer in Visual Studio, you can control the files that are deployed by right clicking on the setup project and selecting View->File System. In the "File Systems on Target Machine" tree, the install location entered by the user will become the "Application Folder" (for WinForms projects) or "Web Application Folder" (for web projects). So by deploying files to that special folder they will be end up in the right place.

d4nt
A: 

Whatever code we write in install method of installer class that will take effect only after installation process is completed. Then how can we change the target directory of installation?