Jump to content

windows xp and win pe each gives diffrent result


vigorman
 Share

Recommended Posts

I do search but no answer.

my source code which is fine in windows xp sp2:

#include <array.au3>
MsgBox(64, "", "driver letter is:" & StringLeft(@ScriptDir,2) & "drive type is:" & DriveGetType(StringLeft(@ScriptDir,2)))

$drives = _GetUSBDrives()

For $i=0 to UBound($drives)-1
    $usbdrv=$usbdrv & $drives[$i] & " "
Next

$usbdrv=StringReplace($usbdrv,"0","") 
$firstU=StringReplace(StringLeft($usbdrv,3)," ","") 
MsgBox(64, "", "first u is: " & $firstu)

Func _GetUSBDrives()
    Local $aDletters[1]  
    $strComputer = "."
    Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
    Local $colDiskDrives = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive")
    For $objDrive In $colDiskDrives
        If $objDrive.pnpdeviceid <> RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk\Enum", _
        RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk\Enum","count")-1) then Continueloop
        $strDeviceID = StringReplace($objDrive.DeviceID, "\", "\\")
        Local $colPartitions = $objWMIService.ExecQuery _
            ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
                $strDeviceID & """} WHERE AssocClass = " & _
                    "Win32_DiskDriveToDiskPartition")    
        For $objPartition In $colPartitions
            Local $colLogicalDisks = $objWMIService.ExecQuery _
                ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
                    $objPartition.DeviceID & """} WHERE AssocClass = " & _
                        "Win32_LogicalDiskToPartition")
            For $objLogicalDisk In $colLogicalDisks
                _ArrayAdd($aDletters,$objLogicalDisk.DeviceID )
            Next
        Next
    Next
    Return $aDletters
EndFunc

but if in PE (1.1) it gives:

Variable must be of type "Object"

could somebody help?

thanks a million.

Edited by vigorman
Link to comment
Share on other sites

I do search but no answer.

my source code which is fine in windows xp sp2:

but if in PE (1.1) it gives:

Variable must be of type "Object"

could somebody help?

thanks a million.

Which variable? $objWMIService, $colDiskDrives, $objDrive, $colPartitions, etc...? Where is is failing?

:P

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...