system.diagnostics.process

  • Thread starter Thread starter miher
  • Start date Start date
M

miher

Hi,
As I know services -by default- run as a user, with no right to show UI. Try
running Your service as a different user (maybe create a new one just for
this).

Hope You find this useful.
-Zsolt
 
hi when i run the below code in a windows app
or a console app notepad opens just fine

when i run it from a Service it does not open in its own window
What is the cause of this
How can get a Service to Spawn and not be hidden

this.psi = new
System.Diagnostics.ProcessStartInfo(this.RunPath+this.RunItem);
this.psi.WindowStyle = ProcessWindowStyle.Maximized;

this.psi.UseShellExecute = true;
this.psi.Verb = "Open";
// this.psi.RedirectStandardInput = true;
// this.psi.RedirectStandardOutput = true;
// this.psi.RedirectStandardError = true;
this.psi.CreateNoWindow = true;
// this.psi.WindowStyle = ProcessWindowStyle.Maximized;

this.oProcess = System.Diagnostics.Process.Start(psi);

Thanks DaveL
 
daveL said:
hi when i run the below code in a windows app
or a console app notepad opens just fine

when i run it from a Service it does not open in its own window
What is the cause of this
How can get a Service to Spawn and not be hidden
By default, services run in a non-interactive window station and cannot
interact with a logged-on user (if there is any). This is usually what you
want. Services typically run unattended and as highly privileged processes,
and it doesn't make sense to spawn windows that a non-privileged user can
interact with.

You first have to make sure what you want. There could be any number of
users logged on, from zero to many (for a Terminal Services service). Which
of these users should see the window? What if there are no users? Do you
really mean to run a process under the service's credentials (usually
LocalSystem, a highly privileged account), potentially allowing users to
compromise the system?

Usually, the solution is not to use a service for this in the first place.
Instead, use a process that automatically starts with user logon. Use a
service only for tasks that need to be performed regardless of whether a
user is logged on. If you need to both do things that must be done if nobody
is logged on *and* some things if somebody is logged on, use both a service
and an autostart process and have them communicate (for example through
named pipes or .NET Remoting).
 
when i use this in production , it will not have interactive rights...i
wanted to know how to do it,
while im testing this...tired of reading logs...

this will be a Task Service Scheduler

there is never no interface with users

Thanks for the help and i did get it to work..
much appriciated
DaveL
 
daveL submitted this idea :
when i use this in production , it will not have interactive rights...i
wanted to know how to do it,
while im testing this...tired of reading logs...

this will be a Task Service Scheduler

there is never no interface with users

Thanks for the help and i did get it to work..
much appriciated
DaveL

I needed a service for something and for testing purposes added a UI
project to the same solution. So the solution could produce two
separate executables: a Windows Service and a regular Winform
application. The shared logic was in a third project.
Maybe you could do something similar?

Hans Kesting
 
Back
Top