Controlling Services with a Script

If you want to automate service control, but you also want to control the startup type, you need to go beyond the command line and create scripts that manage your services. Windows Management Instrumentation (WMI) has a class called Win32_Service that represents a Windows service. You can return an instance of this class to work with a specific service on Windows 8. After you have the service object, you can query its current status with the State property, determine whether the service is running with the Started property, and return the service’s startup type with the StartMode property. You can also change the service state using the StartService, StopService, PauseService, and ResumeService methods.

Listing ...

Get Windows 8 In Depth now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.