Services

  • Thread starter Thread starter Infotech
  • Start date Start date
I

Infotech

I created a script that changes a services startup type to manual, then
starts it and runs a command that uses that service. What I need to do now
is stop the service and set it back to disabled. When I specify to do this
later in the script it stops the service to quick, and doesn't set it to
disable. How can I do this while allowing the command time to run?

Thanks for any help and information.
 
You should intercept your process startup and stop events, possibly using
the Win32_ProcessStartTrace and Win32_ProcessStopTrace events to trigger
your service disable or stop routine.

select * from win32_processStopTrace where processName = "calc.exe"

Would fire an event to the client any time a process named calc.exe closed.

If working with OS's prior to WinXP you can also detect this state with a
slightly different EventNotificationQuery:

select * from __instanceDeletionEvent within 5 where targetInstance isa
"win32_process" and targetInstance.caption = "calc.exe"

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
Infotech said:
I created a script that changes a services startup type to manual, then
starts it and runs a command that uses that service. What I need to do now
is stop the service and set it back to disabled. When I specify to do this
later in the script it stops the service to quick, and doesn't set it to
disable. How can I do this while allowing the command time to run?
Hi

After initializing the stop command, you can go into a loop and wait
for the status to be "stopped" before you continue, here is an example:

http://groups.google.com/[email protected]
 
Win32_ProcessStartTrace

Please, any know some sample working using Win32_ProcessStartTrace??

I have proyect VB.Net using Form, Thank you.
 
Back
Top