/build/static/layout/Breadcrumb_cap_w.png

Alternate choice for LIKE on Windows 2000?

Hey guys,

Ok, here's a line of code (Vbscript) that works fine on Windows XP, but on Windows 2000 gives a charming error #80041017 which is probably related to the use of LIKE which from what I read, was introduced in Windows XP.

Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where Name Like '%network\\admin%' and Drive = 'C:'")

How could I rewrite this to have it working for 2000?

Thanks for your help!

Stephane

PS: If you need the whole code, just tell me, it's 10-15 lines long.

0 Comments   [ + ] Show comments

Answers (3)

Posted by: anonymous_9363 15 years ago
Red Belt
0
How could I rewrite this to have it working for 2000?You could use the right tool to begin with, Stephane! :)

There are innumerable examples of recursive folder searching on the web using the FileSystemObject object. Here's one http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/6c989ba336722877 (see Bruce M. Axten's post). The variable-naming is suspect but at least it works. Add some proper error-trapping, too.

EDIT:
Another http://psacake.com/web/func/dirsrch_object.htm
You'll need to remove the ASP stuff (%< and >%) but other than that, it's ready to go.
Posted by: MRaybone 15 years ago
Senior Yellow Belt
0
Stephane, below are 2 code examples. The 1st is for Windows XP/2003 using 'LIKE', the 2nd is what I had to use to get the same result under Windows 2000:

WINXP/2003:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuickFixes = objWMIService.ExecQuery("Select * from Win32_QuickFixEngineering WHERE HotFixID LIKE '%" & strHotFixID & "%'")
For Each objQuickFix in colQuickFixes
Install_Flag = True
Next


WIN2000:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuickFixes = objWMIService.ExecQuery("Select * from Win32_QuickFixEngineering")
For Each objQuickFix in colQuickFixes
If instr(ucase(objQuickFix.HotFixID), strHotFixID) > 0 then
Install_Flag = True
End If
Next


Not that it matters, but the code example here is from a piece which checks for the presence of particular hotfixes.
You're basically using the instr() function to check each item of your entire list of potential results, instead of using 'LIKE' to select the results directly.

Hope this helps!
MRaybone.
Posted by: Fau 15 years ago
Senior Purple Belt
0
Spot on guys!

It worked!!!

Thanks again for your help!

Stephane
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ