Sign in to follow this  
Followers 0
cjconstantine

WMI and Vista

5 posts in this topic

The code below works fine on my XP box but my Vista box does something a bit odd ... I don't get any object errors but $objItem.Size and $objItem.FreeSpace both return nothing while $objItem.DeviceID and $objItem.VolumeName both return the correct information.

UAC and firewall are disabled. Setting $sIPaddress = '.' makes no difference. Any ideas on what's happening?

$objWMIService = ObjGet('winmgmts:\\' & $sIPaddress & '\root\CIMV2')
If IsObj($objWMIService) Then
    $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_LogicalDisk Where DriveType=3 ', 'WQL', $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        For $objItem In $colItems
            _GUICtrlListView_AddItem($hLVIEW_Drives, $objItem.DeviceID & ' [' & $objItem.VolumeName & ']')

            $iIndex = _GUICtrlListView_GetItemCount($hLVIEW_Drives) - 1
            _GUICtrlListView_AddSubItem($hLVIEW_Drives, $iIndex, $objItem.FileSystem, 1)
            _GUICtrlListView_AddSubItem($hLVIEW_Drives, $iIndex, StringFormat('%.2f', $objItem.Size / (1024 ^ 3)) & ' GB', 2)
            _GUICtrlListView_AddSubItem($hLVIEW_Drives, $iIndex, StringFormat('%.2f', $objItem.FreeSpace / (1024 ^ 3)) & ' GB', 3)
            _GUICtrlListView_AddSubItem($hLVIEW_Drives, $iIndex, StringFormat('%.2f', $objItem.FreeSpace / $objItem.Size * 100) & ' %', 4)

            If StringLeft(_GUICtrlListView_GetItemText($hLVIEW_Drives,  $iIndex, 0), 1) = 'c' Or StringLeft(_GUICtrlListView_GetItemText($hLVIEW_Drives,  $iIndex, 0), 1) = 'd' Then
                _GUICtrlListView_SetItemChecked($hLVIEW_Drives, $iIndex, True)
            EndIf
        Next
    EndIf
EndIf

The DriveGet commands work fine on the Vista box, but ultimately the script needs to get this data from remote PCs.

Share this post


Link to post
Share on other sites



The code below works fine on my XP box but my Vista box does something a bit odd ... I don't get any object errors but $objItem.Size and $objItem.FreeSpace both return nothing while $objItem.DeviceID and $objItem.VolumeName both return the correct information.

UAC and firewall are disabled. Setting $sIPaddress = '.' makes no difference. Any ideas on what's happening?

The DriveGet commands work fine on the Vista box, but ultimately the script needs to get this data from remote PCs.

I have not been afflicted with Vista yet, but perhaps it has the same issue as Windows Server 2003 in KB832479 (which I do have)?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

try #requireadmin (shouldnt matter but this is vista were talking about)... dunno beyond that...

Share this post


Link to post
Share on other sites

@PsaltyDS

From what I read this only affects removable devices DriveType=3 only detects fixed drives.

@botanic

The ID I'm using has admin rights.

Share this post


Link to post
Share on other sites

Working fine for me (Vista Ultimate SP1).

Had to change it a bit to see that it works (for me):

$out = ''

$objWMIService = ObjGet('winmgmts:\\.\root\CIMV2')
    $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_LogicalDisk Where DriveType=3')
    
        For $objItem In $colItems
            $out &= $objItem.DeviceID & ' [' & $objItem.VolumeName & '], size: ' & StringFormat('%.2f', $objItem.Size / (1024 ^ 3)) & ' GB, free space: ' & StringFormat('%.2f', $objItem.FreeSpace / (1024 ^ 3)) & ' GB' & @CRLF
        ;ConsoleWrite($objItem.DeviceID & ' [' & $objItem.VolumeName & '], size: ' & StringFormat('%.2f', $objItem.Size / (1024 ^ 3)) & ' GB, free space: ' & StringFormat('%.2f', $objItem.FreeSpace / (1024 ^ 3)) & ' GB' &@CRLF)
        Next
 
ConsoleWrite($out)
MsgBox(0,'', $out)

btw, "#requireadmin" has very little to do with yours admin rights


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0