Jump to content
Sign in to follow this  
vigorman

windows xp and win pe each gives diffrent result

Recommended Posts

vigorman

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
JerryD

Windows PE doesn't have WMI support.

You can try XPE Plugin with BartPE, but I haven't been able to get it to work yet!

Edited by JerryD

Share this post


Link to post
Share on other sites
MadBoy

Windows PE doesn't have WMI support.

You can try XPE Plugin with BartPE, but I haven't been able to get it to work yet!

Win PE 2.0 have WMI support. So just use newer version :P


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites
vigorman

Thanks to everybody.

I will try pe 2.0.

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  

×