# 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.
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
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).
0
Author Commented:
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)
0
Commented:
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,
0
Commented:
Try running msiexec as follows:

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


See if that does what you need.

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

0
Author Commented:
sorry but none of the proposed solution's worked. I'm currently considering creating a scheduled task to run the msi installation file.

Thnaks
0

Experts Exchange Solution brought to you by