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.
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.
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)
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.RedirectStandardOutp ut = true;
pinfo.CreateNoWindow = true;
pinfo.RedirectStandardErro r = true;
pinfo.RedirectStandardInpu t = 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,
pinfo.UseShellExecute = false;
pinfo.ErrorDialog = false;
pinfo.WindowStyle = ProcessWindowStyle.Hidden;
pinfo.RedirectStandardOutp
pinfo.CreateNoWindow = true;
pinfo.RedirectStandardErro
pinfo.RedirectStandardInpu
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:
See if that does what you need.
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");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
solution not found
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).