Several Methods for operating the Startup Type of Windows Service

Source: Internet
Author: User

1. Use the WMI console to provide the most intuitive control over services
Of course this is not what we need.

2. manipulate the configuration information in the Registry

1. Start Registry Editor (regedt32.exe ).
2. From the registry menu, click Select computer. Type in the name of the computer that is not responding, and then click OK.
3. Locate the following registry key:

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ EventLog
4. Edit the following entries:

Value Name: Start
Data Type: REG_DWORD
Data: 3 (default: 2)

(Data values are 0 = boot, 1 = system, 2 = automatic, 3 = manual, 4 = disabled)

Registry operation content from http://support.microsoft.com /? Kbid = 158995
Knowing which key value in the registry is modified, it is very convenient to use. NET programming.

3. WMI programming: Use Vbscript

Strcomputer = "."
Set ob1_miservice = GetObject ("winmgmts :"_
& "{Impersonationlevel = impersonate }! \ "& Strcomputer &" \ Root \ cimv2 ")
Set colrunningservices = obw.miservice. execquery _
("Select * From win32_service where name = 'cisvc '")
For each objservice in colrunningservices
Wscript. Echo objservice. displayname & vbtab & objservice. State
Errreturncode = objservice. Change (, "automatic ")
Objservice. startservice ()
Wscript. Echo objservice. displayname & vbtab & objservice. State
Next

AboveCodeObtained from the Microsoft technet Script Center.

4. WMI programming: use. net
In fact, the previous VBScript programming is for WMI. You can also program WM using. NET programming.
Related materials are: Windows Management Instrumentation (Wmi ),
ExampleArticle:
Monitoring Application health with WMI and. net
WMI scripting Primer: Part 1
WMI scripting Primer: Part 2

5. Programming: P/invoke and. netProgram

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.