Solved

Vbscript : I need to kill a service using vbs

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
is there a way to grey-out all the controls within a windows screen in VBA 18 33
Everything left of comma in excel 4 48
Index Match Formula VBA 6 47
using vb script 5 47
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

680 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