O'Reilly logo

Windows 8 In Depth by Paul McFedries, Brian Knittel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required