![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | what does the '48' mean? Found a script that tries to determine whether a PC is a desktop or laptop. One of the lines of code is: Set colItems = objWMIService.ExecQuery( "Select * from Win32_Battery", , 48 ) Does anyone know what the 48 refers to? Thanks. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: what does the '48' mean? 48 brings up a yellow box with an Exclamation mark in it. "Tony Logan" <TonyLogan@xxxxxx> wrote in message news:4B1DD4D9-325C-4CE0-9FC3-938A94D51271@xxxxxx Quote: > Found a script that tries to determine whether a PC is a desktop or > laptop. > One of the lines of code is: > Set colItems = objWMIService.ExecQuery( "Select * from Win32_Battery", , > 48 ) > Does anyone know what the 48 refers to? > Thanks. |
My System Specs![]() |
| | #3 (permalink) |
| | RE: what does the '48' mean? "Tony Logan" wrote: Quote: > Found a script that tries to determine whether a PC is a desktop or laptop. > One of the lines of code is: > Set colItems = objWMIService.ExecQuery( "Select * from Win32_Battery", , 48 ) > Does anyone know what the 48 refers to? > Thanks. 48 = wbemFlagForwardOnly (32) + wbemFlagReturnImmediately (16), which means that you can enumerate colItems only once and you can't use colItems.Count. Also, if there is an error, it is not reported untill you try to access colItems. -- urkec |
My System Specs![]() |
| | #4 (permalink) |
| | Re: what does the '48' mean? "urkec" <urkec@xxxxxx> wrote in message news:9DB1C913-DBCD-4384-ABEB-420C3DDF9242@xxxxxx Quote: > "Tony Logan" wrote: > Quote: >> Found a script that tries to determine whether a PC is a desktop or >> laptop. >> One of the lines of code is: >> Set colItems = objWMIService.ExecQuery( "Select * from Win32_Battery", , >> 48 ) >> Does anyone know what the 48 refers to? >> Thanks. > > 48 = wbemFlagForwardOnly (32) + wbemFlagReturnImmediately (16), which > means > that you can enumerate colItems only once and you can't use > colItems.Count. > Also, if there is an error, it is not reported untill you try to access > colItems. contains any items or not. I'm hoping you or someone has a way to find out if the collection has any items without resorting to handling the error that occurs when you try to access it. Also, is it necessary to use the two flags in the 48? Can other, more friendly flags be used? If so, what might they be? Thanks in advance, -Paul Randall |
My System Specs![]() |
| | #5 (permalink) |
| | Re: what does the '48' mean? "Paul Randall" <paulr90@xxxxxx> wrote in message news:OchrrR09IHA.4456@xxxxxx Quote: > > "urkec" <urkec@xxxxxx> wrote in message > news:9DB1C913-DBCD-4384-ABEB-420C3DDF9242@xxxxxx Quote: >> "Tony Logan" wrote: >> Quote: >>> Found a script that tries to determine whether a PC is a desktop or >>> laptop. >>> One of the lines of code is: >>> Set colItems = objWMIService.ExecQuery( "Select * from Win32_Battery", , >>> 48 ) >>> Does anyone know what the 48 refers to? >>> Thanks. >> >> 48 = wbemFlagForwardOnly (32) + wbemFlagReturnImmediately (16), which >> means >> that you can enumerate colItems only once and you can't use >> colItems.Count. >> Also, if there is an error, it is not reported untill you try to access >> colItems. > I see that TypeName(colItems) returns SWbemObjectSet whether the > collection contains any items or not. I'm hoping you or someone has a way > to find out if the collection has any items without resorting to handling > the error that occurs when you try to access it. > > Also, is it necessary to use the two flags in the 48? Can other, more > friendly flags be used? If so, what might they be? making good use of constants as a way to make the intent of one's code clearer. /Al |
My System Specs![]() |
| | #6 (permalink) |
| | Re: what does the '48' mean? Paul Randall schrieb: Quote: > "urkec" <urkec@xxxxxx> wrote in message > news:9DB1C913-DBCD-4384-ABEB-420C3DDF9242@xxxxxx Quote: >> "Tony Logan" wrote: >> Quote: >>> Found a script that tries to determine whether a PC is a desktop or >>> laptop. >>> One of the lines of code is: >>> Set colItems = objWMIService.ExecQuery( "Select * from Win32_Battery", , >>> 48 ) >>> Does anyone know what the 48 refers to? >>> Thanks. >> 48 = wbemFlagForwardOnly (32) + wbemFlagReturnImmediately (16), which >> means >> that you can enumerate colItems only once and you can't use >> colItems.Count. >> Also, if there is an error, it is not reported untill you try to access >> colItems. > I see that TypeName(colItems) returns SWbemObjectSet whether the collection > contains any items or not. I'm hoping you or someone has a way to find out > if the collection has any items without resorting to handling the error that > occurs when you try to access it. > > Also, is it necessary to use the two flags in the 48? Can other, more > friendly flags be used? If so, what might they be? > > Thanks in advance, > -Paul Randall > > http://msdn.microsoft.com/en-us/libr...70(VS.85).aspx or here: http://msdn.microsoft.com/en-us/libr...07(VS.85).aspx For (some of) the numerical values see http://msdn.microsoft.com/en-us/library/cc215511.aspx http://msdn.microsoft.com/en-us/library/cc215515.aspx To make sure and to get a complete list, look into the pertinent header file (provider.h (?)). Whether all flags work as expected with your version of OS, WSH, VBScript, and WMI remains to be seen. |
My System Specs![]() |
| | #7 (permalink) |
| | Re: what does the '48' mean? "Paul Randall" wrote: Quote: > > "urkec" <urkec@xxxxxx> wrote in message > news:9DB1C913-DBCD-4384-ABEB-420C3DDF9242@xxxxxx Quote: > > "Tony Logan" wrote: > > Quote: > >> Found a script that tries to determine whether a PC is a desktop or > >> laptop. > >> One of the lines of code is: > >> Set colItems = objWMIService.ExecQuery( "Select * from Win32_Battery", , > >> 48 ) > >> Does anyone know what the 48 refers to? > >> Thanks. > > > > 48 = wbemFlagForwardOnly (32) + wbemFlagReturnImmediately (16), which > > means > > that you can enumerate colItems only once and you can't use > > colItems.Count. > > Also, if there is an error, it is not reported untill you try to access > > colItems. > I see that TypeName(colItems) returns SWbemObjectSet whether the collection > contains any items or not. I'm hoping you or someone has a way to find out > if the collection has any items without resorting to handling the error that > occurs when you try to access it. > > Also, is it necessary to use the two flags in the 48? Can other, more > friendly flags be used? If so, what might they be? > > Thanks in advance, > -Paul Randall > > > other flags, you can use colItems.Count (even if the collection is empty) and enumerate it more than once: Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_Battery") WScript.Echo TypeName(colItems) WScript.Echo colItems.Count For Each objItem In colItems WScript.Echo objItem.Name Next If you use wbemFlagForwardOnly (32), you can't use colItems.Count and you can enumerate it only once: Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_Battery", , _ wbemFlagReturnImmediately + wbemFlagForwardOnly) WScript.Echo TypeName(colItems) 'WScript.Echo colItems.Count For Each objItem In colItems WScript.Echo objItem.Name Next If you use wbemFlagReturnImmediately and there is an error, it is reported only when you try to use colItems Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_InvalidClass", , _ wbemFlagReturnImmediately + wbemFlagForwardOnly) ' The error is reported here For Each objItem In colItems WScript.Echo objItem.Name Next If you use wbemFlagReturnWhenComplete (0) the error is reported on ExecQuery call: ' The error is reported here Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_InvalidClass", , _ wbemFlagReturnWhenComplete) For Each objItem In colItems WScript.Echo objItem.Name Next -- urkec |
My System Specs![]() |
| | #8 (permalink) |
| | Re: what does the '48' mean? "urkec" <urkec@xxxxxx> wrote in message news:9C202CA9-CFF3-4D6D-995C-B03656B668AA@xxxxxx Quote: > "Paul Randall" wrote: > Quote: >> >> "urkec" <urkec@xxxxxx> wrote in message >> news:9DB1C913-DBCD-4384-ABEB-420C3DDF9242@xxxxxx Quote: >> > "Tony Logan" wrote: >> > >> >> Found a script that tries to determine whether a PC is a desktop or >> >> laptop. >> >> One of the lines of code is: >> >> Set colItems = objWMIService.ExecQuery( "Select * from Win32_Battery", >> >> , >> >> 48 ) >> >> Does anyone know what the 48 refers to? >> >> Thanks. >> > >> > >> > 48 = wbemFlagForwardOnly (32) + wbemFlagReturnImmediately (16), which >> > means >> > that you can enumerate colItems only once and you can't use >> > colItems.Count. >> > Also, if there is an error, it is not reported untill you try to access >> > colItems. >> I see that TypeName(colItems) returns SWbemObjectSet whether the >> collection >> contains any items or not. I'm hoping you or someone has a way to find >> out >> if the collection has any items without resorting to handling the error >> that >> occurs when you try to access it. >> >> Also, is it necessary to use the two flags in the 48? Can other, more >> friendly flags be used? If so, what might they be? >> >> Thanks in advance, >> -Paul Randall Quote: > If you use wbemFlagForwardOnly (32), you can't use colItems.Count and you > can enumerate it only once: most obstinate, useless type of collection'. Why would anyone knowingly ask for this? Is it quicker, use less resourses, or ??? -Paul Randall |
My System Specs![]() |
| | #9 (permalink) |
| | Re: what does the '48' mean? "Paul Randall" <paulr90@xxxxxx> wrote in message news:ORgXYr%239IHA.3344@xxxxxx Quote: > > "urkec" <urkec@xxxxxx> wrote in message > news:9C202CA9-CFF3-4D6D-995C-B03656B668AA@xxxxxx Quote: >> "Paul Randall" wrote: >> Quote: >>> >>> "urkec" <urkec@xxxxxx> wrote in message >>> news:9DB1C913-DBCD-4384-ABEB-420C3DDF9242@xxxxxx >>> > "Tony Logan" wrote: >>> > >>> >> Found a script that tries to determine whether a PC is a desktop or >>> >> laptop. >>> >> One of the lines of code is: >>> >> Set colItems = objWMIService.ExecQuery( "Select * from >>> >> Win32_Battery", , >>> >> 48 ) >>> >> Does anyone know what the 48 refers to? >>> >> Thanks. >>> > >>> > >>> > 48 = wbemFlagForwardOnly (32) + wbemFlagReturnImmediately (16), which >>> > means >>> > that you can enumerate colItems only once and you can't use >>> > colItems.Count. >>> > Also, if there is an error, it is not reported untill you try to >>> > access >>> > colItems. >>> >>> I see that TypeName(colItems) returns SWbemObjectSet whether the >>> collection >>> contains any items or not. I'm hoping you or someone has a way to find >>> out >>> if the collection has any items without resorting to handling the error >>> that >>> occurs when you try to access it. >>> >>> Also, is it necessary to use the two flags in the 48? Can other, more >>> friendly flags be used? If so, what might they be? >>> >>> Thanks in advance, >>> -Paul Randall Quote: >> If you use wbemFlagForwardOnly (32), you can't use colItems.Count and you >> can enumerate it only once: > To me that indicates the 32 flag means 'Please, please, please, give me > the most obstinate, useless type of collection'. Why would anyone > knowingly ask for this? Is it quicker, use less resourses, or ??? > > -Paul Randall http://msdn.microsoft.com/en-us/libr...80(VS.85).aspx. For scripts posted in a support group, I think I would avoid the 32 flag to make the collection more user friendly when the user modifies the code to understand it better. -Paul Randall |
My System Specs![]() |