How to determine the location of install files

J

JDS

I am using a setup project and Windows Installer to deploy my
application and have some additional code in custom actions. In this
code I need to refer to one of the install files but I cannot find how
to determine the path. For example, if the install CD is in the d:
drive and the user runs d:\setup.exe I want to know that it has been
run from d: (rather than e: or any other location) so that I can build
up the path to one of the folders on the CD.

I do not want to copy the file as part of the installation because it
is large and not required once installation is complete.

Can anyone help?
 
F

Family Tree Mike

JDS said:
I am using a setup project and Windows Installer to deploy my
application and have some additional code in custom actions. In this
code I need to refer to one of the install files but I cannot find how
to determine the path. For example, if the install CD is in the d:
drive and the user runs d:\setup.exe I want to know that it has been
run from d: (rather than e: or any other location) so that I can build
up the path to one of the folders on the CD.

I do not want to copy the file as part of the installation because it
is large and not required once installation is complete.

Can anyone help?

If you select the action to install your application and look at the
properties of it you can see the following property: CustomActionData Here
you type:/INSTALLDIR="[TARGETDIR]". In your installer class you can get the
parameter: Context.Parameters.Item("TARGETDIR"). This is how I find files in
the target directory. I believe the SOURCEDIR is what you want.
 
J

JDS

If you select the action to install your application and look at the
properties of it you can see the following property: CustomActionData Here
you type:/INSTALLDIR="[TARGETDIR]". In your installer class you can get the
parameter: Context.Parameters.Item("TARGETDIR"). This is how I find files in
the target directory. I believe the SOURCEDIR is what you want.

Fantastic, thanks very much for this. I think it is nearly there bar a
couple of quirks.

I have set the CustomActionData to /mysource="[SOURCEDIR]\" and then
in code refered to Context.Parameters.Item("mysource"). I found some
more information, including listings of all Windows Installer
properties at:
http://helpnet.installshield.com/robo/projects/installshield11helplib/IHelpInstallerProperties.htm
and
http://helpnet.installshield.com/robo/projects/installshield11helplib/IHelpPropReference.htm

This works fine for a first install but if the program is already
installed and the user selects "repair" then they get an error message
"Exception occurred while initializing the installation:
System.IO.FileNotFoundException: Could not load file or assembly
'file:///C:\WINDOWS\system32\Files.....' or one of its dependencies.
The system cannot find the file specified.". This is frustrating
because the error message is meaningless to most users and there does
not seem to be any way of handling the error. The only option I seem
to have is to include instructions to say that repair is not an
option; the user has to uninstall first.

The other quirk is that the built-in Windows Installer parameter
SETUPEXEDIR seems to be a better option than the SOURCEDIR (see link
above) but when I use this I get the FileNotFoundException (as above)
in all circumstances.

Any help on either of these greatly appreciated.
 
F

Family Tree Mike

JDS said:
If you select the action to install your application and look at the
properties of it you can see the following property: CustomActionData Here
you type:/INSTALLDIR="[TARGETDIR]". In your installer class you can get the
parameter: Context.Parameters.Item("TARGETDIR"). This is how I find files in
the target directory. I believe the SOURCEDIR is what you want.

Fantastic, thanks very much for this. I think it is nearly there bar a
couple of quirks.

I have set the CustomActionData to /mysource="[SOURCEDIR]\" and then
in code refered to Context.Parameters.Item("mysource"). I found some
more information, including listings of all Windows Installer
properties at:
http://helpnet.installshield.com/robo/projects/installshield11helplib/IHelpInstallerProperties.htm
and
http://helpnet.installshield.com/robo/projects/installshield11helplib/IHelpPropReference.htm

This works fine for a first install but if the program is already
installed and the user selects "repair" then they get an error message
"Exception occurred while initializing the installation:
System.IO.FileNotFoundException: Could not load file or assembly
'file:///C:\WINDOWS\system32\Files.....' or one of its dependencies.
The system cannot find the file specified.". This is frustrating
because the error message is meaningless to most users and there does
not seem to be any way of handling the error. The only option I seem
to have is to include instructions to say that repair is not an
option; the user has to uninstall first.

The other quirk is that the built-in Windows Installer parameter
SETUPEXEDIR seems to be a better option than the SOURCEDIR (see link
above) but when I use this I get the FileNotFoundException (as above)
in all circumstances.

Any help on either of these greatly appreciated.

The installshield product and its options are often slightly different than
the visual studio installer switches. Unfortunately they are better
documented than the visual studio installer.

When you run the repair option, are you running from the control panel or
from the install media?
 
J

JDS

The installshield product and its options are often slightly different than
the visual studio installer switches. Unfortunately they are better
documented than the visual studio installer.

When you run the repair option, are you running from the control panel or
from the install media?- Hide quoted text -

- Show quoted text -

I agree, the Visual Studio installer does not seem to be very well
documented.

The error occurs when I select the repair option when running
setup.exe from the install media but I have not ried running from the
control panel.
 
F

Family Tree Mike

JDS said:
I agree, the Visual Studio installer does not seem to be very well
documented.

The error occurs when I select the repair option when running
setup.exe from the install media but I have not ried running from the
control panel.

Is your custom code (DLL) referenced within the install and commit phases?
Even if you don't do an "install" action, but just a "commit" as I usually
do, you need to do this. I got similar errors. I got errors during both
types of installs though.

I suspect then that when repairing, it does something slightly different
than when installing. I don't have any of my install projects here at home.
I will try to diagnose from my office computer at the next opportunity.
 
J

JDS

Is your custom code (DLL) referenced within the install and commit phases?
Even if you don't do an "install" action, but just a "commit" as I usually
do, you need to do this. I got similar errors. I got errors during both
types of installs though.

I suspect then that when repairing, it does something slightly different
than when installing. I don't have any of my install projects here at home.
I will try to diagnose from my office computer at the next opportunity.- Hide quoted text -

- Show quoted text -

Yes, I only have code for commit. However, I tried adding a reference
to the install and still the same error on repair.

I have a form in my class (frmPostInstall) and all I have done in the
install action is to declare a new dummy form and then set it to
Nothing as follows:

Public Overrides Sub Install(ByVal stateSaver As
System.Collections.IDictionary)
Dim DummyForm As New frmPostInstall
Try
MyBase.Install(stateSaver)
DummyForm = Nothing
Catch ex As Exception
MsgBox("Custom action error on install: " & ex.Message)
End Try
End Sub

I don't know if this should be sufficient.

Thanks for your help.
 
F

Family Tree Mike

JDS said:
Yes, I only have code for commit. However, I tried adding a reference
to the install and still the same error on repair.

I have a form in my class (frmPostInstall) and all I have done in the
install action is to declare a new dummy form and then set it to
Nothing as follows:

Public Overrides Sub Install(ByVal stateSaver As
System.Collections.IDictionary)
Dim DummyForm As New frmPostInstall
Try
MyBase.Install(stateSaver)
DummyForm = Nothing
Catch ex As Exception
MsgBox("Custom action error on install: " & ex.Message)
End Try
End Sub

I don't know if this should be sufficient.

Thanks for your help.

Bummer...

I got to work and tested a solution similar to what we are discussing, and
get the same error that you describe when I run the repair mode on my app. I
thought I had mine running. I will continue working this and if I find
anything, post back here. There must be some easy fix to this, you would
think...
 
J

JDS

Bummer...

I got to work and tested a solution similar to what we are discussing, and
get the same error that you describe when I run the repair mode on my app. I
thought I had mine running. I will continue working this and if I find
anything, post back here. There must be some easy fix to this, you would
think...- Hide quoted text -

- Show quoted text -

Yes, you'd think ....

Thanks for having a look at this. Don't worry about progressing on my
account as the repair option is not really going to be that useful on
my app anyway and I will just include instructions to remove first if
it ever comes to that. However, it seems frustrating that it behaves
this way and I'm sure it will help someone else if there was an
answer.

Thanks again for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top