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.
or1969Asked:
Who is Participating?
 
or1969Connect With a Mentor 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
 
unknown_routineCommented:
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
 
or1969Author 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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
unknown_routineCommented:
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
 
willaienCommented:
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

0
 
or1969Author Commented:
solution not found
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.