Re: Windows Services
From: Ken Cox [Microsoft MVP] (BANSPAMken_cox_at_sympatico.ca)
Date: 01/26/05
- Next message: MWells: "Re: BackColor on Label doesn't seem to work"
- Previous message: MWells: "Re: ky with http in value causes debug to fail"
- In reply to: mp: "Windows Services"
- Next in thread: Steve C. Orr [MVP, MCSD]: "Re: Windows Services"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 25 Jan 2005 19:16:06 -0500
That's off topic for an ASP.NET newsgroup but I'd look at the permissions
for the account that is running the batch file when you aren't.
It probably isn't allowed to interact with the desktop or something. Better
to take this issue to microsoft.public.dotnet.framework.component_services .
"mp" <john88m@hotmail.com> wrote in message
news:ObfHwJzAFHA.3708@TK2MSFTNGP14.phx.gbl...
>I start a service and I have the following code:
>
> //This code is Service2
> if(Directory.Exists(pathFinal) && Directory.Exists(PathIntermediate))
>
> {
>
> m_threadFinal = new Thread(new System.Threading.ThreadStart(BuildFile));
>
> m_threadFinal.Start();
>
>
> }
>
>
>
> private void BuildFile()
>
> {
>
> //all code works here
>
> //Then when I am done I want to stop my service and restart another
> service
>
> DoThe magic();
>
> }
>
>
>
> Private void DoTheMagic()
>
> {
>
> //want to stop service2 itself and restart service1
>
> try
>
> {
>
>
>
> ServiceController scStop = new ServiceController("service2");
>
> ServiceRunning=false;
>
> scStop.Stop();
>
> scStop.Close();
>
> ServiceController sc1 = new ServiceController("service1");
>
> if (sc1.Status.Equals(ServiceControllerStatus.Stopped))
>
> {
>
> sc1.Start();
>
> }
>
> }
>
> catch(Exception ex)
>
> {
>
> System.Diagnostics.EventLog.WriteEntry("error" + ex.Message ,
> System.Diagnostics.EventLogEntryType.Error);
>
> }
>
> }
>
> I do a Net Stop "service1" which works fine
> then I do a Net Start "service2" , actually these are in bat files.
> This works if i set schedule and run them manually , but If i wait for it
> to
> run the next day, service2 does not stop!!!!!!!!!!!!!!! so weired!!!! can
> anyone help???
>
> Thanks
>
>
- Next message: MWells: "Re: BackColor on Label doesn't seem to work"
- Previous message: MWells: "Re: ky with http in value causes debug to fail"
- In reply to: mp: "Windows Services"
- Next in thread: Steve C. Orr [MVP, MCSD]: "Re: Windows Services"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|