How to get the location where user ask msi to install the application

  • Thread starter Thread starter vidishasharma
  • Start date Start date
V

vidishasharma

Hi,

I want to get the location which user selects for installaion of
program using msi installer. I require this to do kind of cleanup
activity if something goes wrong with the installation.

Regards,
Vidisha
 
Yes I tries that thanks for answering However I want both /
SrcDir="[SourceDir]\" and /TrgDir="[TARGETDIR]\"

however when I give /SrcDir="[SourceDir]\" , /TrgDir="[TARGETDIR]\"
for my custom action it does not work. How can I get both.
 
Thanks that actually worked.

To confirm I want to ask I have to check some conditions from
SourceDir and if it fails then I have to rollback the installation.
However it looks like I have to write a program to delete the files
from TARGETDIR as it does not get deleted automatically.

Please confirm.
 
It sounds like, based on some condition within the source installation, you
want to uninstall after begining the install, via a custom action. To be
honest, I have never had need to do this intentionally. I have had occasion
where this occurs via an error being thrown in my custom action. Therefor, I
would recommend throwing an exception from your custom action code, such as
New Exception("You have a stolen source disk"). This install should then
"fail" more or less gracefully.
 
Yes I do that
InstallException("Installer failed");

however files from the target directory do not get removed. So I have
to remove it by my program.

Do you recommed this.
 
Strange... My experience is the files got removed. I guess you will need to
do it manually in your code.
 
some of the files are used in the targetdir and therefore it is
throwing an exception and not leting me delete the files :(
 
Can you move your checks from the SourceDir to occur in the OnBeforeInstall
event? This is presuming you are doing it in the Commit event now.
 
Hi I am checking it in OnBeforeInstall, however all the files do not
get deleted


if (!File.Exists(filepath))
{
if (Directory.Exists(targetPath))
{
string[] files =
Directory.GetFiles(targetPath);
foreach (string str in files)
{
try
{
File.Delete(str);
}
catch
{ }
}
try
{
Directory.Delete(targetPath);
}
catch { }
}



throw new InstallException("Installer downloaded
is corrupted. Please download again");

}

If I just throw the InstallException without programatically deleteing
files then cleaup is not proper. therefore I have to delete the files
for proper cleanup. still some file remain in targetdirectry as they
are used by some process

Can you point it what wrong I am doing.
 
I'm sorry, but I am at a loss as to why files would be in the target from
your install when checked in the OnBeforeInstall custom action.
 
they are temp files created at the process of installation. As even in
before install all the files in msi are downloaded to the location
where we want to install the program.

Correct me if I am wrong.
 
Back
Top