Re: How to start another program in Windows Service?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

The problem you have is that notepad is an interactive program,.the service
do not have a "display" where to show the notepad window, remember that the
service is running even if nobody is logged on the computer
The same thing happen when you are starting the service, if you have it
declared as "automatic" it's started when windows is starting, at that
moment you still have the windows startup screen.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Dao" <hungtdao@xxxxxxxxx> wrote in message
news:c190ca3d-dd4a-41ae-9768-56c2bb3df818@xxxxxxxxxxxxxxxxxxxxxxx
>I have created a windows service called MyService. I followed the MSDN
>sample code to add the following code but it did not work. What I tried
>was that to start another or external program when MyService starts. I
>used notepad.exe as an example of a program to be called when MyService
>starts. I have tried both in the InitializationComponenet() then in the
>OnStart() Method but none of them work. Any help would be appreciated.
>
> private void InitializeComponent()
> {
> this.process1 = new System.Diagnostics.Process();
> //
> // process1
> //
> this.process1.StartInfo.FileName = "c:\\WINDOWS\\notepad.exe";
> this.ServiceName = "MyService";
> }
>
> I also tried this:
>
> protected override void OnStart(string[] args)
> {
> // TODO: Add code here to start your service.
> System.Diagnostics.Process p = new System.Diagnostics.Process();
> p.StartInfo.FileName = "c:\\windows\\notepad.exe";
> }
>
>
>
>
>
> From
> http://www.developmentnow.com/g/36_2005_4_0_17_0/dotnet-languages-csharp.htm
>
> Posted via DevelopmentNow.com Groups
> http://www.developmentnow.com


.



Relevant Pages

  • Re: how to run app from service
    ... It's not so easy to perform what are u trying to do and this is a bad behavior (iterating services with desctop options is removed in the forthcoming version of windows). ... I recomend u to put user depended code for start in the Starup folder ... W> starts Notepad - notepad window is not visible but process is there. ... W> Process myProcess = new Process; ...
    (microsoft.public.dotnet.general)
  • Re: Can scheduled task close a running application ?
    ... Just try the example I gave, open up a Notepad window then run the script to see it close the open Notepad window. ... Windows VBScript Utilities» www.billsway.com/vbspage/ ... >> automatically using scheduled task (Control Panel - ...
    (microsoft.public.windowsxp.general)
  • Windows Explorer bug: Steals ctrl+x keystroke from other applications
    ... Running Windows 2000. ... text in the Notepad window. ... Hit CTRL-X. ... explorer c:\Program Files\Internet Explorer ...
    (microsoft.public.win2000.general)
  • Re: sasser
    ... > shuts down before windows allows me to do anything so i ... Spyware Blaster ...
    (microsoft.public.scripting.virus.discussion)
  • Re: how to make a python windows service know its own identity
    ... I have used the win32com libraries to set up a service called ... MyService under Windows. ... process multiple providers (store them in a list or other ...
    (comp.lang.python)