|
-
December 12th, 2008, 05:49 AM
#1
Starting a Windows Service Programattically
I have a program which sets the .config file of a windows service and then starts the service. The problem I'm having i can only get the service to start if the program terminates immediately after starting the service, however i want to wait for 30 seconds and then stop the service before terminating the program.
the code i use to start the service is:
scnService = New ServiceController
With scnService
.MachineName = "."
.ServiceName = "SERVICENAME"
.Start()
End With
End
After doing some investigating i found that if i put any code after .Start() the Status of the Service is set to 2 (StartWithPending - i don't know what this means) however if i immediately terminate the program the Status of the Service is set to 4 (Running). How do i set the Status to 4 without terminating the program?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|