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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

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
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
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
or1969Author Commented:
solution not found
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.