Solved

Wait till Finished Process

Posted on 2004-10-06
4
271 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
Comment Utility
> NTServiceManager1.ActiveService := true;

What does this line do exactly ?
0
 
LVL 6

Accepted Solution

by:
vadim_ti earned 100 total points
Comment Utility
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
Comment Utility
maybe like this:

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

Author Comment

by:sfern
Comment Utility
Just what i needed.

Thanks a Million :o)

SFern.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now