PC Review Forums Newsgroups Windows XP Windows XP WMI Services

Reply

Services

 
Thread Tools Rate Thread
Old 28-06-2004, 02:57 PM   #1
Infotech
Guest
 
Posts: n/a
Default Services


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.

--
Infotech


  Reply With Quote
Old 28-06-2004, 07:35 PM   #2
[MS] Scott McNairy
Guest
 
Posts: n/a
Default Re: Services

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" <df> wrote in message
news:%23S$Yl%23RXEHA.1656@TK2MSFTNGP09.phx.gbl...
> 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.
>
> --
> Infotech
>
>



  Reply With Quote
Old 29-06-2004, 09:40 AM   #3
Torgeir Bakken \(MVP\)
Guest
 
Posts: n/a
Default Re: Services

Infotech wrote:

> 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/groups?sel...2C2%40hydro.com


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/co...er/default.mspx
  Reply With Quote
Old 26-12-2005, 05:10 AM   #4
vitoto
Junior Member
 
Join Date: Nov 2005
Posts: 3
Trader Rating: (0)
Default Win32_ProcessStartTrace

Please, any know some sample working using Win32_ProcessStartTrace??

I have proyect VB.Net using Form, Thank you.
vitoto is offline   Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off