In the previous program, when we “stop” the service, if it is successfully stopped, we receive zero as the returned value. I stated that a non-zero value gets returned if unsuccessful. Using this value, we can figure out why it failed to “stop” (or “start” as well). The following table gives the list of return values and descriptions for both methods “StopService” and “StartService”.
By using the “Select..Case” statement with the return code, we can display properly using the definitions from the above table. Even though I copied the above table from WMI SDK documentation, I thought it was worthwhile to include the table as part of this article to provide you with complete information.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |