T Torgeir Bakken (MVP) Aug 25, 2003 #2 Steve said: What is the command syntax to stop a service on a remote computer? Click to expand... Hi Sysinternals has a command line utility PsService that can do this: http://www.sysinternals.com/ntw2k/freeware/pstools.shtml ADSI can also be used for this (local and remote), here is a vbscript: sComputer = "." ' use "." for local machine sService = "messenger" If StopService(sService, sComputer) Then WScript.Echo sService & " stopped" Else WScript.Echo "Failed to connect to the service " & sService End If Function StopService(sService, sNode) Const ADS_SERVICE_STOPPED = 1 Dim oComputer, oService Set oComputer = GetObject("WinNT://" & sNode & ",computer") On Error Resume Next Set oService = oComputer.GetObject("Service", sService) If Err.Number <> 0 Then StopService = False Exit Function End If If oService.Status <> ADS_SERVICE_STOPPED Then oService.Stop WScript.Sleep 1000 End If StopService = True End Function
Steve said: What is the command syntax to stop a service on a remote computer? Click to expand... Hi Sysinternals has a command line utility PsService that can do this: http://www.sysinternals.com/ntw2k/freeware/pstools.shtml ADSI can also be used for this (local and remote), here is a vbscript: sComputer = "." ' use "." for local machine sService = "messenger" If StopService(sService, sComputer) Then WScript.Echo sService & " stopped" Else WScript.Echo "Failed to connect to the service " & sService End If Function StopService(sService, sNode) Const ADS_SERVICE_STOPPED = 1 Dim oComputer, oService Set oComputer = GetObject("WinNT://" & sNode & ",computer") On Error Resume Next Set oService = oComputer.GetObject("Service", sService) If Err.Number <> 0 Then StopService = False Exit Function End If If oService.Status <> ADS_SERVICE_STOPPED Then oService.Stop WScript.Sleep 1000 End If StopService = True End Function
S Scott Losawyer Aug 27, 2003 #3 netsvc from the resource kit: NETSVC servicename \\computername /command or SC from the resource kit: sc <server> [command] [service name]
netsvc from the resource kit: NETSVC servicename \\computername /command or SC from the resource kit: sc <server> [command] [service name]