WSH Architecture

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

When you learn how to drive a car, you do not need to first become an expert on the internal combustion engine or fluid dynamics. If you can distinguish between the gas and the brake pedal and figure out how the steering wheel works, you probably will be able to get from Point A to Point B.

And that is perfectly fine, assuming that after you get to Point B you will get out of the car and never drive again. But what if you want to drive on a regular basis? In that case, it helps to understand a little bit about how cars work, and why they might not work. You should know that cars require gas, that tires require air, and that batteries will run down if the lights are left on. If you do not understand these basic principles of cars, you are likely headed for some unpleasant surprises.

The same is true of scripting. If all you want to do is use a script to stop the Alerter service on the local computer, there is no need to read this book and to memorize the ins and outs of scripting. Instead, just copy and run the following:

strComputer = "." Set objWMIService = GetObject("winmgmts:" _     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colServices = objWMIService.ExecQuery _     ("SELECT * FROM Win32_Service WHERE Name = 'Alerter'") For Each objService in colServices     errReturnCode = objService.StopService() Next 

But what happens if you want to stop a different service, or you want to stop a service on a remote computer? What happens if you want to start the Alerter service? If you want to modify existing scripts or if you want to create your own scripts, you need to understand how scripting works. This understanding requires at least a passing familiarity with the WSH architecture.


send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net