?
Solved

Vbscript : I need to kill a service using vbs

Posted on 2007-11-27
3
Medium Priority
?
1,060 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month16 days, 14 hours left to enroll

864 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