0

I want to silently install an application named Instacal within my Custom Action written in C#. In this custom action i am also installing other applications and this works fine(they are not silently installed!).

When the silent installation of the application named Instacal is started, nothing is ever installed(i check Programs and Features). In my Custom Action I do the following:

int ms = 0;
// execute InstaCal silently - it must be present on the user machine!
var fileName = Path.Combine(folder3rdParty, @"Instacal\InstaCal.msi");
Process installerProcess;
installerProcess = Process.Start(fileName, "/q");
while (installerProcess.HasExited == false)
{
     StreamWriter file = new StreamWriter("c:\\test.txt", true);
     file.WriteLine("ms: " + ms);
     file.Close();

     Thread.Sleep(250);
     ms += 250;
}

I am writing to a file just to test how long time the installaltion approximately takes. It takes about 3 seconds in the while loop and afterwards nothing is installed.

But if i use the exactly same code in a small console application then the application Instacal is succesfully installed silently. This installation take about 9 seconds to complete.

So, am i doing something wrong in the code? Am i missing something important regarding custom actions? thx :)

Diemauerdk
  • 5,238
  • 9
  • 40
  • 56
  • 2
    Hi @user1093774 I assume that you're using Wix installer. If so why don't you use Wix Bootstrapper to perform the installation for you? – Johan J v Rensburg Aug 18 '14 at 09:44
  • 2
    Also use the msiexec /l*v option to create a log. – Polyfun Aug 18 '14 at 09:46
  • Thx for the fast reply! :) I am not using Wix installer. Another in my project decided how to do the installation. I have no knowledge about Wix either. So at the moment Wix are not an option :( – Diemauerdk Aug 18 '14 at 09:51
  • @user1093774 then it might be that you're install is not running under different user with insufficient permissions, to perform the installation. – Johan J v Rensburg Aug 18 '14 at 09:53
  • On another note @user1093774 why are you using a CustomAction to install the msi? Was this just the way you got the project? And if you dont' mind which installer are you using? – Johan J v Rensburg Aug 18 '14 at 09:55
  • Yes i thought of that too but I have tried to install with administrator rights but it's still failing. – Diemauerdk Aug 18 '14 at 09:56
  • I havent much experience with installers but it's a normal Setup Project from within visual studio. And yes when i got this project Custom actions was used to install other msi and exe files. Should it be done in another way than custom actions? – Diemauerdk Aug 18 '14 at 10:00
  • @user1093774 try the following Process installerProcess = Process.Start( "msiexec", string.Format("/i /q '{0}'",fileName) ); – Johan J v Rensburg Aug 18 '14 at 10:05
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/59495/discussion-between-johan-j-v-rensburg-and-user1093774). – Johan J v Rensburg Aug 18 '14 at 10:07

1 Answers1

1

I would suggest that you change your code to the following:

This then uses the MSIEXEC command to install your package instead of calling the MSI directly.

int ms = 0;
// execute InstaCal silently - it must be present on the user machine!
var fileName = Path.Combine(folder3rdParty, @"Instacal\InstaCal.msi");
Process installerProcess;
installerProcess = Process.Start("msiexec", string.Format("/i '{0}' /q", fileName));
while (installerProcess.HasExited == false)
{
     StreamWriter file = new StreamWriter("c:\\test.txt", true);
     file.WriteLine("ms: " + ms);
     file.Close();

     Thread.Sleep(250);
     ms += 250;
}
  • I tried what you suggested, but with no luck. When the process is started, a messagebox appears giving me some install options. The only thing i can do about this messagebox is to hit the button OK and it closes without installing anything :(. – Diemauerdk Aug 19 '14 at 06:34
  • Hi @user1093774 the message box appears because it not able to run the msi. Are you sure the files is deployed at the correct location? Debug the CustomAction and then just copy and paste the fileName value and go to cmd and run msiexec /i '#paste fileName value' – Johan J v Rensburg Aug 20 '14 at 12:40