Re: Executing an application inside a Service

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Chakkaradeep (Chakkaradeep_at_discussions.microsoft.com)
Date: 12/01/04


Date: Wed, 1 Dec 2004 11:23:08 -0800

hi all,

check out this link,this article shows how to run applications using NT
Service written in C,so when it can be done there why cant it be done in
C#???....

http://www.codeproject.com/system/xyntservice.asp

with regards,
C.C.Chakkaradeep

"John M Deal" wrote:

> One of these days I'll have to go through and test this so I can stop
> talking theory, but for now here is what I have heard and believe will
> work "in theory:"
>
> You should be able to go into the service mmc snap-in and set the
> properties of the service and set it to allow the service to interact
> with the desktop. You'll obviously want to test this to see if it works
> but I think it is sound, however as others have mentioned this setting
> will only work (if at all) if someone is actively logged on to the system.
>
> If you don't mind some design advice, I would recommend that you split
> this into two different applications. One a service that listens for
> connections and another that gets started when a user logs on to the
> desktop. The startup application would register with the service to be
> passed notification that the "calc.exe" application should be started
> and then the startup application would run "calc.exe". This would allow
> you to have the functionality that you are looking for, not be worried
> about whether or not a service can run something on the desktop, and
> allow remote workstations to register and receive the same kinds of
> messages/application startups as the local system. Just a thought.
>
> Have A Better One!
>
> John M Deal, MCP
> Necessity Software
>
> P.S. Please let me/us know if you decide to try the interactive desktop
> option and whether or not it works.
>
> Chakkaradeep wrote:
> > Hi,
> >
> > sorry friends,i forgot to add someting IMPORTANT in previous post...i opened
> > up my Task Manager and found instances of "calc.exe" running which was
> > started by my Service...but GUI has not shown ???......
> >
> > this service is important for me becoz am monitoring a port regularly and
> > have to start my client application as and when i get request....
> >
> > there is no means that we can start an application using Services???...if
> > there is,then can anyone tell me code for that or link??
> >
> > with regards,
> > C.C.Chakkaradeep
> >
> > "Chakkaradeep" wrote:
> >
> >
> >>Hi,
> >>
> >>My application which to be made run by my Service is a GUI application say
> >>"somename.exe",service has to just make it run....for this also i need to
> >>spawn a thread???
> >>
> >>with regards,
> >>C.C.Chakkaradeep
> >>
> >>"Nicholas Paldino [.NET/C# MVP]" wrote:
> >>
> >>
> >>>Chakkaradeep,
> >>>
> >>> Does the account that the service is running under have the appropriate
> >>>permissions? Does the application you are running have a UI, or is it a
> >>>console app?
> >>>
> >>>--
> >>> - Nicholas Paldino [.NET/C# MVP]
> >>> - mvp@spam.guard.caspershouse.com
> >>>
> >>>"Chakkaradeep" <Chakkaradeep@discussions.microsoft.com> wrote in message
> >>>news:7D37DC29-255F-4FEA-B1B0-D62F64FAFCCE@microsoft.com...
> >>>
> >>>>Hi,
> >>>>
> >>>>My Service is a Multithreaded Server which listens for connections at a
> >>>>particular port....if any incoming connections come,the server accepts it
> >>>>and
> >>>>starts an application with the parameter got from remote end by receiving
> >>>>the
> >>>>informations from Socket....this is what i want to do...i have developed a
> >>>>Multithreaded Server runnning as service,it is working fine by sending
> >>>>back
> >>>>replies to clients....but am not able to execute an application....
> >>>>
> >>>>so what is my next step??...am a newbie to Services...
> >>>>
> >>>>with regards,
> >>>>C.C.Chakkaradeep
> >>>>
> >>>>"Nicholas Paldino [.NET/C# MVP]" wrote:
> >>>>
> >>>>
> >>>>>Chakkaradeep,
> >>>>>
> >>>>> What's happening when you run it? Running another program from
> >>>>>inside a
> >>>>>service isn't the best idea in the world, especially if it has a UI. If
> >>>>>it
> >>>>>has a UI, then you have to let the service interact with the desktop, and
> >>>>>even then, you can't guarantee that there will be a desktop session
> >>>>>(there
> >>>>>is none if no one is logged in).
> >>>>>
> >>>>> What are you trying to do?
> >>>>>
> >>>>>
> >>>>>--
> >>>>> - Nicholas Paldino [.NET/C# MVP]
> >>>>> - mvp@spam.guard.caspershouse.com
> >>>>>
> >>>>>"Chakkaradeep" <Chakkaradeep@discussions.microsoft.com> wrote in message
> >>>>>news:D45C58E9-5B5E-4DBF-BBAD-8C8D2E2BDF75@microsoft.com...
> >>>>>
> >>>>>>Hi all,
> >>>>>>
> >>>>>>i have written a Service,now i want to execute another application (for
> >>>>>>eg;calc.exe) in the service....how will i perform it??...
> >>>>>>
> >>>>>>i tried using this....
> >>>>>>
> >>>>>>/**************Executing a Process code starts here**************/
> >>>>>>System.Diagnostics.Process proc = new System.Diagnostics.Process();
> >>>>>>proc.EnableRaisingEvents=false;
> >>>>>>proc.StartInfo.FileName="calc";
> >>>>>>proc.Start();
> >>>>>>/**************Executing a Process code ends here**************/
> >>>>>>
> >>>>>>the above code is not working.......what is the other alternative or is
> >>>>>>my
> >>>>>>approach wrong??...
> >>>>>>
> >>>>>>with regards,
> >>>>>>C.C.Chakkaradeep
> >>>>>
> >>>>>
> >>>>>
> >>>
> >>>
>



Relevant Pages

  • Re: MCU/DSP dsPIC Alternatives?
    ... > some applications I would be considering. ... > admit this chip seems dsPICable, er, I mean pretty nice. ... as you needed to set the ARP (Auxiliary Register Pointer ...
    (comp.arch.embedded)
  • Java Web Console completely empty
    ... I now started the webconsole for the first time. ... Console, or you have no rights to use any applications ... I guess I need to register some applications. ...
    (comp.unix.solaris)
  • Re: Cant delete an assembly from the GAC!
    ... How does one register that a certain assembly depends on another? ... > applications have registered their references to this GACed assembly using ... it may also be that the DLL file is simply locked ...
    (microsoft.public.dotnet.framework)
  • Re: how to find other computers connected to the same router
    ... My Computer / Manage / Services and Applications / Services ... Log On as: Local System ... > Apologizes... ...
    (microsoft.public.windowsxp.network_web)
  • Registering .net dll as a COM
    ... I created an assembly for very common purposes, ... Those applications can be managed and unmanaged. ... For unmanaged code I created another assembly which is really just a COM ... should be registered as a COM (I use Register property and set it into ...
    (microsoft.public.dotnet.framework.interop)