Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change Service from Automatic to manual

642 views
Skip to first unread message

Inaki

unread,
Jun 13, 2002, 2:01:49 PM6/13/02
to
I am triing to make a script to change service that is running in windows xp
from automatic to manual ¿Is the any way in Vbscript?? how??any examples???


Torgeir Bakken

unread,
Jun 13, 2002, 4:08:48 PM6/13/02
to
Inaki wrote:

> I am triing to make a script to change service that is running in windows xp
> from automatic to manual ¿Is the any way in Vbscript?? how??any examples???

------------------------------------------------------------
VBScript/WMI:

Configure Service Start Options
http://www.microsoft.com/technet/scriptcenter/services/scrsvc03.asp

Change Method in Class Win32_Service (used in example above)
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/change_method_in_class_win32_service.asp

- alternativly -
ChangeStartMode Method in Class Win32_Service
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/changestartmode_method_in_class_win32_service.asp

An example on ChangeStartMode:

From: msnews.microsoft.com (Matthew....@Eclipsys.com)
Subject: services, stopping/starting, changing startup type
Newsgroups: microsoft.public.scripting.wsh
Date: 2001-10-19 08:56:09 PST
http://groups.google.com/groups?hl=en&lr=&ie=UTF8&oe=UTF8&th=97f321a49155f0c0

------------------------------------------------------------
VBScript/ADSI:

IADsService
http://msdn.microsoft.com/library/en-us/netdir/adsi/iadsservice.asp

Example:

sComputer = CreateObject("WScript.Network").ComputerName
sService = "some service"

Set oSvc = GetObject("WinNT://" + sComputer + "/" + sService)
' Set to Manual
oSvc.StartType = ADS_SERVICE_DEMAND_START
oSvc.SetInfo

------------------------------------------------------------
Pure VBScript (RegWrite)

This can be be done by writing a DWORD with valuedata 3 to the value "Start"
under
HKLM\SYSTEM\CurrentControlSet\Services\<service>

Set oShell = CreateObject("WScript.Shell")
' Set the DCHP service to manual
oShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\DHCP\Start", _
3, "REG_DWORD"

--
torgeir


0 new messages