Vbscript to change windows service startuptype

I am using the below command line code to change the start up type of some of my services to automatic-delayed.

sc config *servicename*  start= delayed-auto

Is there a way to do this in VBscript? Or can the above command line be converted to VBScript?

Upvotes: 1

Views: 2241

Answers (2)

Garric
Garric

Reputation: 724

    Set WshShell = CreateObject("WScript.Shell" ) 
    WshShell.Run chr(34) & "sc.exe"" config *servicename* start=demand""" & Chr(34), 0, false
    Set WshShell = Nothing 

    ' auto--a service automatically started at boot time, even if no user logs on
    ' boot--a device driver loaded by the boot loader
    ' demand--a service that must be manually started (the default)
    ' disabled--a service that can't be started
    ' system--a service started during kernel initialization
    ' delayed-auto ???????????
    ' 0 - hidden, 1 - normal mode 2 - minimized view 3 - expanded view

Upvotes: 1

GTAVLover
GTAVLover

Reputation: 1427

Use Run Method

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "CMD /C sc config *servicename*  start= delayed-auto", 0, True

Upvotes: 2

Related Questions