Link to home
Start Free TrialLog in
Avatar of or1969
or1969

asked on

C# : install .msi file from a service

I've created a service that will run an .msi installation file using the ProcessInfo class.

The problem is that nothing is installed.
Running the same code from a standard Winform application, the .msi file is installed successfully.

The service and the Winform version are running using the local administrator account.
Avatar of unknown_routine
unknown_routine
Flag of United States of America image

This is a good question.

The reason for the behavior is winows services do run on isolated sessions and by design cannot interact with user applications(such as windows or console applications).

Therefore a windows service cannot run an executable file(such as msi or exe).
Avatar of or1969
or1969

ASKER

But if I run calc (for example), the process calc is started but without GUI and I don't need the GUI.

for installing 7Zip (for example) adding the argument /quite will install the application with showing any GUI. But it won't work when running from the service.

Is there a workaround? There are application that can install application from a service (wsus, ca)
Try to force process info  disable any windows or frames:

pinfo.UseShellExecute = false;
pinfo.ErrorDialog = false;
pinfo.WindowStyle = ProcessWindowStyle.Hidden;
pinfo.RedirectStandardOutput = true;
pinfo.CreateNoWindow = true;
pinfo.RedirectStandardError = true;
pinfo.RedirectStandardInput = true;


Also make sure  checkbox under the Log on tab in the properties window, for a Windows service that is called "Allow service to interact with desktop."  is checked,
Try running msiexec as follows:

msiexec.exe /i \path\to\file.msi /quiet

Open in new window


See if that does what you need.

Process.Start("msiexec.exe","/i \\path\\to\\file.msi /quiet");

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of or1969
or1969

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of or1969

ASKER

solution not found