#77291 - 2003-10-29 04:44 PM
WMI
|
Bob Deerinwater
Starting to like KiXtart
Registered: 2002-05-05
Posts: 101
Loc: Covina California
|
I have found a wmi script that will get the drive size, but it works half the time. it appears that if the drive is less than 10 gig it will not work. Here is the code code:
$objWMIService = GetObject( "winmgmts://./root/cimv2" ) If @ERROR GoTo ShowError EndIf $colItem1 = $objWMIService.ExecQuery( "Select * from Win32_Processor", , 48 ) $colItem2 = $objWMIService.ExecQuery( "Select * from Win32_LogicalMemoryConfiguration", , 48 ) $colItem3 = $objWMIService.ExecQuery( "Select * from Win32_DiskDrive", , 48 )
For Each $objItem In $colItem1 $clockspeed = $objItem.CurrentClockSpeed Next For Each $objItem In $colItem2 $memory=( ( $objItem.TotalPhysicalMemory + 1023 ) / 1024 ) Next For Each $objItem In $colItem3 $Sice = $objItem.Size $LSize = Len( $Sice ) $MSize = SubStr( $Sice, 1, $LSize - 3 ) $Size = ( 524288 + $MSize ) / 1048576 Next
|
|
Top
|
|
|
|
#77292 - 2003-10-29 05:18 PM
Re: WMI
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
have a look at WMIQuery() UDF
|
|
Top
|
|
|
|
#77294 - 2003-10-29 06:57 PM
Re: WMI
|
Bob Deerinwater
Starting to like KiXtart
Registered: 2002-05-05
Posts: 101
Loc: Covina California
|
I copied this code from another place and after runing it out on paper it basically puthe the drive information into a 2 character number. that is what i am assuming at this time. i could be wrong. What i am going for is to put the drive into a one or 2 character number ie...4 10 20 to determine the drive in gigabytes. if there is another way i would be up for any suggestions
|
|
Top
|
|
|
|
#77295 - 2003-10-29 07:08 PM
Re: WMI
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
$HD =WMIQuery("Size","Win32_DiskDrive")[0] $hdGB =left($hd,len($hd)-9)
|
|
Top
|
|
|
|
#77297 - 2003-10-29 07:23 PM
Re: WMI
|
Bob Deerinwater
Starting to like KiXtart
Registered: 2002-05-05
Posts: 101
Loc: Covina California
|
I feel just a little stupid right now. Did not even think of removing the last 9 characters. Thank You
|
|
Top
|
|
|
|
#77298 - 2003-10-29 07:26 PM
Re: WMI
|
Bob Deerinwater
Starting to like KiXtart
Registered: 2002-05-05
Posts: 101
Loc: Covina California
|
i am not using the wmiquery() udf as of now so this is what i did. I do not have any drive less that 1gig so it shouls work code:
For Each $objItem In $colItem3 $hd = $objItem.Size $hdGB =Left($hd,Len($hd)-9) Next
|
|
Top
|
|
|
|
#77300 - 2003-10-29 08:17 PM
Re: WMI
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
it works fine for my 6, 10, 20, and 40 gb drives
|
|
Top
|
|
|
|
#77302 - 2003-10-29 09:25 PM
Re: WMI
|
Bob Deerinwater
Starting to like KiXtart
Registered: 2002-05-05
Posts: 101
Loc: Covina California
|
I keep getting erro on expression when i use code:
$mb=$kb/1024
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 811 anonymous users online.
|
|
|