Pastetool #99

URL: , Paste another

' StopService (VBS)
' ServiceName  is case sensitive.
Public Function StopService(ServiceName)    
    dim objWMIService, objService
    dim strComputer
    strComputer = "."
    
    Set objWMIService = GetObject("winmgmts:" _ 
        & "{impersonationLevel=impersonate}!\\" _
        & strComputer & "\root\cimv2")

    dim colListOfServices
    Set colListOfServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where Name = """ & ServiceName & """ ")
    
    if colListOfServices.count then
        For Each objService in colListOfServices
            objService.StopService()
        Next
        
        StopService = true
        exit function
    end if
    StopService = false
End Function

Download code

This visual basic code was pasted on September 30, 2009




Protected with advance Anti-SPAM techniques :)
Coded and designed by Fedmich
Follow us on Twitter