Jump to content

hvandrie

Members
  • Posts

    5
  • Joined

  • Last visited

Recent Profile Visitors

119 profile views

hvandrie's Achievements

  1. Thx, Mr Creator. There's a little bug though... the "To" word has become a reserved word in AutoItv3 as of version 3.3.12.0 (https://www.autoitscript.com/trac/autoit/ticket/2768) Think it will be a little challenge to fix this one as you're using the CDO.Message COM object directly. Don't know whether there are aliases of some kind to work around this issue. Edit: Think you have to revise your CDO.Message function to use the Recipient property or Recipients collection object instead.
  2. Trolleule, For whatever it's worth, I've written myself one...
  3. Hi, Have been using this UDF, and added another function to it for the people to use: _WIM_GetMountedImageInfo ; #FUNCTION# ==================================================================================================================== ; Name...........: _WIM_GetMountedImageInfo ; Description ...: Returns list of mounted images ; Syntax.........: _WIM_GetMountedImageInfo() ; Parameters ....: ; Return values .: Success - Returns Array where [0][0] holds number of mounted images, each subsequent row holds information to each image ; Failure - Returns 0 and Sets @Error: ; |0 - No DLLCall error. ; |1 - Unable to use the DLL file ; |2 - Unknown "return type" ; |3 - "function" not found in the DLL file ; |4 - Bad number of parameters. ; Both - Sets @Extended to _WinAPI_GetLastError() ; Author(s) .....: Herman van Drie (hvandrie) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; ; ; =============================================================================================================================== Func _WIM_GetMountedImageInfo() Local $aReturn[2][4] Local $pWimMountList = DllStructCreate($tagWIM_MOUNT_LIST) Local $pWimMountInfoLevel1 = DllStructCreate($tagWIM_MOUNT_INFO_LEVEL1) Local $pWimMountImageCount = DllStructCreate("dword pdwImageCount;") Local $pWimMountListSize = DllStructCreate("dword pcbReturnLength;") Local $aResult $aResult = DllCall($ghwimgapi, "bool", "WIMGetMountedImageInfo", _ "int", 1, _ "ptr", DllStructGetPtr($pWimMountImageCount), _ "ptr", DllStructGetPtr($pWimMountList), _ "dword", DllStructGetSize($pWimMountList), _ "ptr", DllStructGetPtr($pWimMountListSize)) If _WinAPI_GetLastError() = 122 Then ; ERROR_INSUFFICIENT_BUFFER 122 (0x7A) : The data area passed to a system call is too small. ; Calculate required buffer / array size Local $iRequiredBufferSizeFactor = Int(DllStructGetData($pWimMountListSize, "pcbReturnLength"))/int(DllStructGetSize($pWimMountList)) Local $tWimMountList ReDim $aReturn[UBound($aReturn,1)+$iRequiredBufferSizeFactor][4] For $i = 1 To $iRequiredBufferSizeFactor $tWimMountList &= $tagWIM_MOUNT_LIST & "; " Next $pWimMountList = DllStructCreate($tWimMountList) ; Retry the call $aResult = DllCall($ghwimgapi, "bool", "WIMGetMountedImageInfo", _ "int", 1, _ "ptr", DllStructGetPtr($pWimMountImageCount), _ "ptr", DllStructGetPtr($pWimMountList), _ "dword", DllStructGetSize($pWimMountList), _ "ptr", DllStructGetPtr($pWimMountListSize)) EndIf $aReturn[0][0]= DllStructGetData($pWimMountImageCount,"pdwImageCount") ; number of mounted images For $i = 0 To $aReturn[0][0] - 1 $aReturn[$i+1][0] = DllStructGetData($pWimMountList, 4*$i+1 ) ; "WimPath" $aReturn[$i+1][1] = DllStructGetData($pWimMountList, 4*$i+2 ) ; "MountPath" $aReturn[$i+1][2] = DllStructGetData($pWimMountList, 4*$i+3 ) ; "ImageIndex") $aReturn[$i+1][3] = DllStructGetData($pWimMountList, 4*$i+4 ) ; "MountedForRW") Next Return SetError(@error, _WinAPI_GetLastError(), $aReturn) EndFunc ;==>_WIM_GetMountedImageInfo Have fun with it!
  4. Already solved it myself. Instead of the variable receiving the object that supposed to be returned immediately, the object had to be set to a specific property that had the object as an value. Const $BCDWindowsImageType = 0x10200003 Const $BCDLegacyImageType = 0x10300006 Const $BCDLibString_Desc = 0x12000004 Const $BcdOSLoaderDevice_OSDevice = 0x21000001 Local $WMILocator = ObjCreate("WbemScripting.SWbemLocator") $WMILocator.Security_.Privileges.AddAsString('SeBackupPrivilege') $WMILocator.Security_.Privileges.AddAsString('SeRestorePrivilege') Local $WMIRootNameSpace = $WMILocator.ConnectServer(@ComputerName, "root\wmi") Local $oStoreClass = $WMIRootNameSpace.Get("BcdStore") Local $objInParam = $oStoreClass.Methods_('OpenStore').InParameters.SpawnInstance_() $objInParam.Properties_.Item('File') = "" Local $oBCDStore = $oStoreClass.ExecMethod_('OpenStore',$objInParam).Store ; The Store property contains our object value If IsObj($oBCDStore) Then Local $oBCDStoreObjects, $objInParam $objInParam = $oBCDStore.Methods_('EnumerateObjects').InParameters.SpawnInstance_() $objInParam.Type = $BCDWindowsImageType $oBCDStoreObjects = $oBCDStore.ExecMethod_('EnumerateObjects', $objInParam).Objects ; The Objects property contains our object value For $oBCDStoreObject in $oBCDStoreObjects MsgBox($MB_ICONWARNING, "debug", $oBCDStoreObject.Properties_.Item('Id').Value) Next EndIf I found the property containing the object value by enumerating through the object properties using the .Properties_ propertyset and display the "Name" of each property item in the set, like: $oBCDStoreObjects = $oBCDStore.ExecMethod_('EnumerateObjects', $objInParam) For $oBCDStoreObject in $oBCDStoreObjects.Properties_ MsgBox($MB_ICONWARNING, "debug", $oBCDStoreObject.Name) Next
  5. Hi, I want to access the BCD (Boot Manager) store for Windows using the BCD WMI Provider. Only, I seem to be unable to create a proper BCDStore object. I am using the following VB code(from Scripting Guys) and am translating it to AutoIT code: Const BcdLibraryString_Description = &h12000004 Const WindowsImages = &h10200003 Const LegacyImages = &h10300006 Const BcdLibraryDevice_ApplicationDevice = &h11000001 Const BcdLibraryDevice_ApplicationPath = &h12000002 Const BcdBootMgrDevice_BcdDevice = &h21000022 Const BcdOSLoaderDevice_OSDevice = &h21000001 strComputer = "." Set objStoreClass = GetObject("winmgmts:{(Backup,Restore)}\\" & _ strComputer & "\root\wmi:BcdStore") objStoreClass.OpenStore "", objStore Wscript.Echo "Windows images | " & WindowsImages objStore.EnumerateObjects WindowsImages, colObjects For Each objObject in colObjects objObject.GetElement BcdLibraryString_Description, objElement Wscript.Echo objElement.String Next Wscript.Echo Executing the following code, in admin context, I can execute the GetSystemPartition method. However, the EnumerateObjects method fails.... Const $BCDWindowsImageType = 0x10200003 Const $BCDLegacyImageType = 0x10300006 Const $BCDLibString_Desc = 0x12000004 Local $WMILocator = ObjCreate("WbemScripting.SWbemLocator") $WMILocator.Security_.Privileges.AddAsString('SeBackupPrivilege') $WMILocator.Security_.Privileges.AddAsString('SeRestorePrivilege') Local $WMIRootNameSpace = $WMILocator.ConnectServer(@ComputerName, "root\wmi") Local $oStoreClass = $WMIRootNameSpace.Get("BcdStore") Local $SystemPart = $oStoreClass.ExecMethod_('GetSystemPartition') MsgBox($MB_ICONWARNING, "debug" , $SystemPart.Partition) MsgBox($MB_ICONWARNING, "debug" , $BCDWindowsImageType) ;$objInParam = "" Local $oBCDStoreObjects $objInParam = $oStoreClass.Methods_('EnumerateObjects').InParameters.SpawnInstance_() $objInParam.Properties_.Item('Type') = $BCDWindowsImageType $oBCDStoreObjects = $oStoreClass.ExecMethod_('EnumerateObjects', $objInParam) MsgBox($MB_ICONWARNING, "debug" , $oBCDStoreObjects.Properties_.Item('ReturnValue').Value) Any help would be greatly appreciated!
×
×
  • Create New...