_NTServices.au3 (9.8K)
Number of downloads: 2060
It provides four major functions: _ServiceStatus(), _ServicePause(), _ServiceStart(), _ServiceStop().
For example, status of IIS Administration Service on local machine can be retrieved like this:
$status = _ServiceStatus("IISAdmin")
According to the service itself, $status could be one of these:
- "Stopped"
- "Start Pending"
- "Stop Pending"
- "Running"
- "Coninue Pending"
- "Pause Pending"
- "Paused"
You can also specify a computer name (or an IP address) in any of these functions, like this:
$result = _ServicePause("IISAdmin", "CatchFishComputer")
If succeeds, it returns 1. Otherwise it returns 0 and sets @error to a non-zero number. The same to _ServiceStart() & _ServiceStop(). Note that controlling remote NT services needs certain privilege through an IPC connection. (See man page of console command "net use" for more information.)
Because these four functions only recognize "internal" service names, so you may need the helper function, _ToInternalServiceName(), to translate the display names that you see in Services Manager. You may do the job in this way:
$result = _ServiceStop( _ToInternalServiceName("Task Scheduler") )
The function above scans the registry to retrieve information. Thus it takes unnecessary time for the convenience. I suggest that you get the internal service name through _ToInternalServiceName() in advance, and then hard-coded that name in the script, if possible.
That's it! Have fun.
This post has been edited by CatchFish: 05 March 2006 - 08:15 AM

Sign In
Register
Help

MultiQuote