#140930 - 2005-06-0304:18 AMRe: Disable and Stop a service
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11631
Loc: CA
Chris,
Yeah looks like you were correct. Looks like he apparently used a combination of some of my code and some of your code which are not set the same, so he should have used your example instead of mixing them. Anyways... that said, if you would make a minor modification to your UDF then it would be able to handle the call better when a computer name is not supplied. Currently your method of the connection is using a UNC even on a local system which means a user must have Admin rights to access it. By making the call to the local namespace without the UNC a user without Admin rights can still run the script. It wouldn't complete the task if the user didn't have Admin rights (it would not be able to modify the service) but the WMI connection would work, so that if it was only a query it would complete.
Here is his code re-worked that should work well. Not really sure what's up with checking a Display Name of one item and then setting another item. Don't have the product installed to confirm why.