Solved

Vbscript : I need to kill a service using vbs

Posted on 2007-11-27
3
1,040 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

19 Experts available now in Live!

Get 1:1 Help Now