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