Solved

Wait till Finished Process

Posted on 2004-10-06
4
274 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 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