Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

services

Status
Not open for further replies.

harpal

Technical User
Oct 3, 2001
115
GB
Hi,

all need help I need some way of stopping a particular service via a batch script is the possible any help welcome

thanks

Harps
 
You could try VBScript

I have to admit that its not easy if you are not familiar with VBScript.

However you try replacing NetDDE with the name of your script.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery("Associators of " _
& "{Win32_Service.Name='NetDDE'} Where " _
& "AssocClass=Win32_DependentService " & "Role=Antecedent" )
For each objService in colServiceList
objService.StopService()
Next
Wscript.Sleep 20000
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='NetDDE'")
For each objService in colServiceList
errReturn = objService.StopService()
Next



See more on VBScript here



Guy Thomas

'Best Practice' Ezine
 
if you want to do it with a batchfile, you could use the "net stop <service>" command (to start use "net start <service>")

The only thing you have check is the name of the service and when it contains spaces use quotes ...
To see the list of running services use "net start"

e.g.

net stop alerter
net stop "DNS Client"

Let me know if this helps ...
G.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top