Jump to content

usb info


Recommended Posts

hi

drive letter for partitions

new usb info

When I added a new usb, new usb dont show partitions

When I added second a new usb ,, old usb shows partitions

$strComputer = "."
 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")

 $colEvents = $objWMIService.ExecNotificationQuery _
    ("Select * From __InstanceOperationEvent Within 5 Where " _
        & "TargetInstance isa 'Win32_LogicalDisk'")

While 1
     $objEvent = $colEvents.NextEvent
    If $objEvent.TargetInstance.DriveType = 2 Then 
        Select 
            Case $objEvent.Path_.Class()="__InstanceCreationEvent"
                Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been added." & @CR)
                newusbinfo()
            Case $objEvent.Path_.Class()="__InstanceDeletionEvent"
                Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been removed."& @CR)
        EndSelect
    EndIf
    $objEvent = $colEvents.NextEvent
    If $objEvent.TargetInstance.DriveType = 3 Then 
        Select 
            Case $objEvent.Path_.Class()="__InstanceCreationEvent"
                Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been added." & @CR)
                
                newusbinfo()
            Case $objEvent.Path_.Class()="__InstanceDeletionEvent"
                Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been removed."& @CR)
        EndSelect
    EndIf

WEnd

func newusbinfo()
 Local $Drive = $objObject.TargetInstance.DeviceId
            $drv &= $objObject.TargetInstance.Description & " " &$Drive & "  " & _
            $objObject.TargetInstance.FileSystem &" VOL: " & _
            $objObject.TargetInstance.VolumeName & @CRLF
         msgbox(0,"_new usb info_ ", $drv)
return
endfunc
Link to comment
Share on other sites

Are you on a network with mapped drives? Sometimes windows doesn't look to see if a drive letter is already in use when an external drive is added. Check "My Computer" and see if there is a unique drive letter assigned to the USB drive. If not, go to the disk management utility to change the drive letter that the USB device is assigned to one that is not already in use.

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...