Solved

Wait till Finished Process

Posted on 2004-10-06
4
275 Views
Last Modified: 2012-05-05
Hi there,

I'm sorry about the points but it's all the points i have left.

This is my problem:

I have this code:

First i have to change the StartType of the Service:

procedure TForm1.Button2Click(Sender: TObject);
begin

//Set the StartType
NTServiceManager1.ServiceAccess := S_ALL_ACCESS;
NTServiceManager1.ServiceName   := 'wuauserv';
NTServiceManager1.ActiveManager := true;
NTServiceManager1.ActiveService := true;
NTServiceManager1.StartType := AUTO_START;
NTServiceManager1.ActiveManager := false;


I Now Start the Service:

//Start the Service
NTServiceManager1.ServiceAccess := S_ALL_ACCESS;
NTServiceManager1.ServiceName   := 'wuauserv';
NTServiceManager1.ActiveManager := true;
NTServiceManager1.ActiveService := true;
NTServiceManager1.Startservice(memo1.Lines);
NTServiceManager1.ActiveManager := false;

My problem is that the program is trying to Start executing the Service while the Startype is still changing and i get an error.

How could i wait for Part 1 to finish and then start part 2?

Thanks

SFern

end;
0
Comment
Question by:sfern
  • 2
4 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12237692
> NTServiceManager1.ActiveService := true;

What does this line do exactly ?
0
 
LVL 6

Accepted Solution

by:
vadim_ti earned 100 total points
ID: 12237702
only suggestion:

//stop service

with NTServiceManager1 do begin
   ManagerAccess := [M_CONNECT, M_ENUMERATE_SERVICE];
    ServiceAccess := [S_ALL_ACCESS];
    ActiveManager := true;
    ServiceName   := 'NetLogon';
    ActiveService := true;
    ControlService(CONTROL_STOP);
    ActiveService := false;
    ActiveManager := false;
end;

//Set the StartType
with NTServiceManager1 do begin
   ManagerAccess := [M_CONNECT, M_ENUMERATE_SERVICE];
    ServiceAccess := [S_ALL_ACCESS];
    ActiveManager := true;
    ServiceName   := 'wuauserv';
    ActiveService := true;
    StartType := AUTO_START;
    ActiveService := false;
    ActiveManager := false;
end;
   
   

// Start the Service:
with NTServiceManager1 do begin
   ManagerAccess := [M_CONNECT, M_ENUMERATE_SERVICE];
    ServiceAccess := [S_ALL_ACCESS];
    ActiveManager := true;
    ServiceName   := 'wuauserv';
    ActiveService := true;
    Startservice(memo1.Lines);;
    ActiveService := false;
    ActiveManager := false;
end;

0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12237715
maybe like this:

try
  //Set the StartType
  ...
finally
  //Start the Service
  ...
end;
0
 

Author Comment

by:sfern
ID: 12237860
Just what i needed.

Thanks a Million :o)

SFern.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question