Windows XP configure service startup mode to Manual

Joined
Jun 22, 2005
Messages
2
Reaction score
0
On Windows 2000 Machine, I need to configure service startup mode to "Manual" using VB/Windows scripts.
Following statements are not working.

Set ErVal = oService.Change( , , , , "demand")
or
Set ErrVal = oService.Change( , , , , "Manual")

ErrVal is 438


Thanks in advance
--Kamesh
 
Joined
Jun 22, 2005
Messages
2
Reaction score
0
Hello Danny
Thanks for your reply here is the code which I have tried with , Plesae find the code which I got from Scripting guide at the bottom
**************firt set of code
sComputer = "." ' use "." for local machine
sService = "ACI SNMP DCNServer EMGEN"

If StopService(sService, sComputer) Then
WScript.Echo sService & " stopped and Changed Startup mode"
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
Exit Function
End If

If oService.Status <> ADS_SERVICE_STOPPED Then
oService.Stop
WScript.Sleep 1000
Set err = oService.Change( , , , , "demand")
WScript.Echo err

End If

StopService = True
End Function

******************second set of statements tried from windiws scripting guide, which gives error number 2*****

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name = 'ACI SNMP DCNServer EMGEN'")
For Each objService in colServiceList
errReturnCode = objService.Change( , , , , "Disabled")
WScript.Echo errReturnCode
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top