Solved

Vbscript : I need to kill a service using vbs

Posted on 2007-11-27
3
1,041 Views
Last Modified: 2012-06-21
please help
0
Comment
Question by:itbabe
3 Comments
 
LVL 11

Expert Comment

by:bsharath
ID: 20356606
Kill a service you mean stop and delete?

Click Start -> Run -> Cmd.exe -> OK
WMIC /NODE:"Remote_Machine_Name_Here" /USER:Administrator /PASSWORD:P@ssW0rd SERVICE WHERE Name="Service_Name_Here" CALL StopService

This will stope and remove a service.

::stop, disable and remove
@Echo Off
setlocal
set service=dwmrcs
FOR /F %%c IN (C:\computers.txt) Do (
      Echo stop service %%c
      sc \\%%c stop %service%
      sc \\%%c config %service% start= disabled
      sc \\%%c delete %service%
)

Save as a bat file and have all the computernames in the txt file
Set the service name
set service=dwmrcs
0
 
LVL 31

Accepted Solution

by:
merowinger earned 500 total points
ID: 20356661
strComputer = "."
Set objWMIService = GetObject("winmgmts:"  & "{impersonationLevel=impersonate}!\\"   & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery  ("Select * from Win32_Service Where Name ='Messenger'")
For Each objService in colListOfServices
    objService.StopService()
    Wscript.Echo "Stopped Messenger service"
Next
0
 
LVL 11

Expert Comment

by:cup
ID: 20357474
Does it really need to be in vbs?  Can't you just do it in a dos box

net stop servicename

To start it

net start servicename
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.
Both in life and business – not all partnerships are created equal. Spend 30 short minutes with us to learn:   • Key questions to ask when considering a partnership to accelerate your business into the cloud • Pitfalls and mistakes other partners…

911 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

21 Experts available now in Live!

Get 1:1 Help Now