Hi,

How coluld we do, via script, in order to deactivate the mensenger service
concerning windows 2000 pro?

thank's

Re: deactive service by Torgeir

Torgeir
Thu Jan 27 14:17:52 CST 2005

keppler wrote:

> How coluld we do, via script, in order to deactivate the
> mensenger service concerning windows 2000 pro?
Hi

Disable the Messenger service (computer will not be able to
receive "net send" messages anymore):


'--------------------8<----------------------

Const ADS_SERVICE_DISABLED = 4
Const ADS_SERVICE_AUTO_START = 2
Const ADS_SERVICE_DEMAND_START = 3

Set oShell = CreateObject("WScript.Shell")
Set oWshNet = CreateObject("WScript.Network")
sComputer = oWshNet.ComputerName

sService = "Messenger"

' set Messenger to Disabled
bOK = ConfigureService(sService, ADS_SERVICE_DISABLED, sComputer)

' stop the messenger service
oShell.Run "net.exe stop """ & sService & """", 0, True

If bOK Then
WScript.Echo sService & " configured"
Else
WScript.Echo "Failed to configure " & sService
End If


Function ConfigureService(sService, iType, sNode)

Dim oComputer, oService
Set oComputer = GetObject("WinNT://" & sNode & ",computer")

On Error Resume Next
Set oService = oComputer.GetObject("Service", sService)
If Err.Number <> 0 Then
ConfigureService = False
Exit Function
End If

If oService.StartType <> iType Then
oService.StartType = iType
oService.SetInfo
WScript.Sleep 1000
End If

ConfigureService = True
End Function


'--------------------8<----------------------


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: deactive service by Keppler

Keppler
Fri Jan 28 10:16:37 CST 2005

Thank's

"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> escreveu na mensagem
news:Oj#LG2KBFHA.3824@TK2MSFTNGP10.phx.gbl...
> keppler wrote:
>
> > How coluld we do, via script, in order to deactivate the
> > mensenger service concerning windows 2000 pro?
> Hi
>
> Disable the Messenger service (computer will not be able to
> receive "net send" messages anymore):
>
>
> '--------------------8<----------------------
>
> Const ADS_SERVICE_DISABLED = 4
> Const ADS_SERVICE_AUTO_START = 2
> Const ADS_SERVICE_DEMAND_START = 3
>
> Set oShell = CreateObject("WScript.Shell")
> Set oWshNet = CreateObject("WScript.Network")
> sComputer = oWshNet.ComputerName
>
> sService = "Messenger"
>
> ' set Messenger to Disabled
> bOK = ConfigureService(sService, ADS_SERVICE_DISABLED, sComputer)
>
> ' stop the messenger service
> oShell.Run "net.exe stop """ & sService & """", 0, True
>
> If bOK Then
> WScript.Echo sService & " configured"
> Else
> WScript.Echo "Failed to configure " & sService
> End If
>
>
> Function ConfigureService(sService, iType, sNode)
>
> Dim oComputer, oService
> Set oComputer = GetObject("WinNT://" & sNode & ",computer")
>
> On Error Resume Next
> Set oService = oComputer.GetObject("Service", sService)
> If Err.Number <> 0 Then
> ConfigureService = False
> Exit Function
> End If
>
> If oService.StartType <> iType Then
> oService.StartType = iType
> oService.SetInfo
> WScript.Sleep 1000
> End If
>
> ConfigureService = True
> End Function
>
>
> '--------------------8<----------------------
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx