Which is the most efficient code
- From: "srp1877" <srpjunk@xxxxxxxxxxx>
- Date: 19 Mar 2007 14:00:25 -0700
Hello
Which out of the following two methods is the most efficient, I think
that the first one is the most effient because it doesn't need to
check every peice of software found, but this is just how it looks to
me, can anyone explain which is actually most efficient or if there is
a better way than the two methods below.
Code 1
strcomputer = "."
strsw = "Microsoft Visio"
set objwmiservice = getobject("winmgmts:
{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2")
set colSoftware = objWMIService.ExecQuery("Select * from Win32_Product
" & "Where Name = " & "'" & strsw & "'")
If colSoftware.Count > 0 Then
for each objsoftware in colsoftware
WScript.Echo objsoftware.Name
next
End If
Code 2
strcomputer = "."
Set objWMIService = GetObject("winmgmts:
{impersonationLevel=impersonate}!\\" & strcomputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery("SELECT * FROM
Win32_Product")
If colSoftware.Count > 0 Then
For Each objSoftware in colSoftware
If InStr(objsoftware.Name, "Microsoft Visio") <> 0 then
WScript.Echo objsoftware.Name
Next
End If
Thanks
Simon
.
- Follow-Ups:
- Re: Which is the most efficient code
- From: asdf
- Re: Which is the most efficient code
- Prev by Date: Please Help
- Next by Date: BUG: WshRemote
- Previous by thread: Please Help
- Next by thread: Re: Which is the most efficient code
- Index(es):
Relevant Pages
|