'Filename: USBPMFIX.VBS
'Version: 1.0.0.3
'Author:   Matthew Mellon <mmellon@ecrs.com>
'Date:     2014-12-12
'Desc:     Disables enhanced power management on all Datalogic USB devices.
'License:  This source code is released into the public domain.  
'
'Dominique: modified on 2016.05.02 for ARM9 based products.  
'           Added old products on 2016.05.19. 

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
 strComputer & "\root\default:StdRegProv")

strKeyPath = "SYSTEM\CurrentControlSet\Enum\USB"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each Subkey in arrSubKeys
  If ((Left(Subkey,9) = "VID_180F&" And Right(Subkey,8) = "PID_1109") Or (Left(Subkey,9) = "VID_180F&" And Right(Subkey,8) = "PID_1107") Or (Left(Subkey,9) = "VID_180F&" And Right(Subkey,8) = "PID_1108") Or (Left(Subkey,9) = "VID_180F&" And Right(Subkey,8) = "PID_1101") Or (Left(Subkey,9) = "VID_180F&" And Right(Subkey,8) = "PID_1104") Or (Left(Subkey,9) = "VID_180F&" And Right(Subkey,8) = "PID_1105") Or (Left(Subkey,9) = "VID_180F&" And Right(Subkey,8) = "PID_1106")) Then 
        strKeyPath = "SYSTEM\CurrentControlSet\Enum\USB\"+Subkey
    objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrInnerSubKeys
    For Each InnerSubkey in arrInnerSubKeys
        strFullKey = "SYSTEM\CurrentControlSet\Enum\USB\"+Subkey+"\"+InnerSubkey+"\Device Parameters"
        objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strFullKey, "EnhancedPowerManagementEnabled", 0
    Next   
  End If
Next