steve1_rm
asked on
getting location of executing setup.exe using custom actions
Hello,
VS 2005 C#
I am using a installer class as I need a custom action that will read in a xml config file.
So when the user double clicks the setup, there will be a config.xml file in the same folder. I would like to read in this config.xml file on install event. The folder will contain setup.exe and config.xml
However, the code gives me the location of where the custom action has been installed to.
What I am looking for is this.
1) The user will download a zip file that will contain a folder with the setup.exe and config.xml.
2) The user can unzip this anywhere on their computer. i.e. desktop.
3) They double click the setup.exe and I would like to get the location of where they have unzipped. Which would be the folder with the setup.exe and config.xml.
4) Its that config.xml I would like to read in.
The config.xml is not packaged in the setup.exe. This is because the client would like to make some changes to the application after the setup.exe has been created.
Actually just to give further information. I give the setup.exe to the client plus a config.xml file, they will zip this up and make it downloadable form their website, so they customers can use it. However, if they want to change something like IP address that the application uses, they can use this config file and get the customers to download again. This is because they don't want to have another setup.exe created.
So that is why I am using the step above,
Many thanks,
VS 2005 C#
I am using a installer class as I need a custom action that will read in a xml config file.
So when the user double clicks the setup, there will be a config.xml file in the same folder. I would like to read in this config.xml file on install event. The folder will contain setup.exe and config.xml
However, the code gives me the location of where the custom action has been installed to.
What I am looking for is this.
1) The user will download a zip file that will contain a folder with the setup.exe and config.xml.
2) The user can unzip this anywhere on their computer. i.e. desktop.
3) They double click the setup.exe and I would like to get the location of where they have unzipped. Which would be the folder with the setup.exe and config.xml.
4) Its that config.xml I would like to read in.
The config.xml is not packaged in the setup.exe. This is because the client would like to make some changes to the application after the setup.exe has been created.
Actually just to give further information. I give the setup.exe to the client plus a config.xml file, they will zip this up and make it downloadable form their website, so they customers can use it. However, if they want to change something like IP address that the application uses, they can use this config file and get the customers to download again. This is because they don't want to have another setup.exe created.
So that is why I am using the step above,
Many thanks,
protected override void OnAfterInstall(System.Collections.IDictionary savedState)
{
// Create a data table to hold the contents of the xml file
DataTable dt = new DataTable();
// Test to see if it is looking for the config in the right location
MessageBox.Show(System.Reflection.Assembly.GetExecutingAssembly().CodeBase.ToString());
// Read in
dt.ReadXml("config.xml");
MessageBox.Show(base.Context.Parameters("CAT_TargetDir").ToString());
}
ASKER
Hello,
Thanks for the advice.
However, the main problem is. Is that I cannot include the config.xml in the setup package. The config.xml is there so that our client can modify some values. If the config.xml is included. Then they cannot do this.
This was what I need to do and our client has requested this. For example there is an server IP address that the application uses. Which is stored in the config.xml. The client doesn't want us to create another setup.exe, as they don't want to wait for us to do one. They just want to change things on the fly. So they make the change to the config file. And their customers will download the zip file that will contain the ordinal setup with the modified config file.
When they double click to install the custom action will read in the config.xml file. However, I am having a problem, as the customer could download and unzip anywhere on their computer. So that is the main problem is getting the location of the config.xml that is contained in the same zipped folder at the setup.
Many thanks for anymore suggestions,
Thanks for the advice.
However, the main problem is. Is that I cannot include the config.xml in the setup package. The config.xml is there so that our client can modify some values. If the config.xml is included. Then they cannot do this.
This was what I need to do and our client has requested this. For example there is an server IP address that the application uses. Which is stored in the config.xml. The client doesn't want us to create another setup.exe, as they don't want to wait for us to do one. They just want to change things on the fly. So they make the change to the config file. And their customers will download the zip file that will contain the ordinal setup with the modified config file.
When they double click to install the custom action will read in the config.xml file. However, I am having a problem, as the customer could download and unzip anywhere on their computer. So that is the main problem is getting the location of the config.xml that is contained in the same zipped folder at the setup.
Many thanks for anymore suggestions,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ID 24184751 is the answer.
You should add the config file to your install project. Then You parse the install path to the installer class:
[RunInstaller(true)]
public partial class Installer1 : Installer
{
public Installer1()
{
InitializeComponent();
}
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
try
{
DoInstall(this.Context.Par
}
catch (Exception e) { MessageBox.Show(e.Message)
}
Context.Parameters["target
/targetdir="[TARGETDIR]\"
That should do the trick.
p.s. Put your install logic in a local method fx. DoInstall