WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WMI
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WQL LIKE Operator


Question:

Could you look at my code below and make sure that it is correct, I am trying to do a "LIKE" for the name of the service in my ExecQuery and keep receiving errors (Not a valide OLE object):
strComputer = "itportal"
objWMIService = GetObject(StrCat("winmgmts:\\" , strComputer , "\root\cimv2"))
colServiceList = objWMIService.ExecQuery("Select * from Win32_Service where Name LIKE 'TSM%%' ") 
ForEach objService in colServiceList
Message("Status", StrCat(objService.DisplayName, " ", objService.State))
Next
colServiceList = 0
objWMIService = 0
exit
I am not sure if I am using the LIKE portion correctly, since a "%" is required after the service name to perform the query. Appreciate your help.

I am using version 2005C

The error I am receiving is:

3131: OleExecute: Not a valid OLE object 
for the line:
Message("Status", StrCat(objService.DisplayName, " ", objService.State)) 

There is nothing in the wwwbatch.ini file. I am going against a remote system and am able to receive return information if I have the exact service name in the query.

I did test using my local machine versus different remote systems and ONLY on the remote systems am I receiving the error. It seems that a remote system is not providing the object information back when using the LIKE comparison operator.

I have tried different 3 letter constructs and different remote systems, and always get the same error.

Answer:

What windows platform is this remote computer. Apparently the WMI WQL syntax on pre-XP machines does not support the LIKE operator...

http://msdn.microsoft.com/library/en-us/wmisdk/wmi/like_operator.asp?frame=true

The remote machine must be windows XP or 2003 in order to support the use of the LIKE operator.

AS an alternative you could just query all of the services then use StrIndexWild to search each of the returned service string for the value you are looking for...


Article ID:   W17326
File Created: 2007:07:03:14:29:30
Last Updated: 2007:07:03:14:29:30