Gregor1806 Posted July 31, 2013 Share Posted July 31, 2013 (edited) Hi folks, Please can someone help. I found the following web article, which explains what I'm trying to do - except I want to do this natively within AutoIt code instead of using the VBS that the link provides: http://www.verboon.info/index.php/2012/12/exploring-the-functions-included-in-microsoft-bdd-utility-dll/ I've been trying to make this work, but so far unsuccessfully. I just keep getting the @error code set to 1 and no results. My attempts are here: expandcollapse popupIf @OSArch = "X86" Then $sDllName = @ScriptDir & "\x86Microsoft.BDD.Utility.dll" ElseIf @OSArch = "X64" Then $sDllName = @ScriptDir & "\x64Microsoft.BDD.Utility.dll" EndIf ;~ $oShell = ObjCreate("WScript.Shell") ;~ $sDllName = @ScriptDir & "\Microsoft.BDD.Utility.dll" ;~ $oShell.Run ("regsvr32.exe /s """ & $sDllName & """", 0, 1) ;~ $oBDDUtility = ObjCreate("Microsoft.BDD.Utility") ;~ $dll = DllOpen($sDllName) ;~ $sIsUEFI = DllCall($dll, "int", "IsUEFI") $sIsUEFI = DllCall($sDllName, "int", "IsUEFI") ;~ $sSupports64Bit = DllCall($dll, "int", "Supports64Bit") MsgBox(0, "", @error) If IsArray($sIsUEFI) Then MsgBox(0, "", "UEFI: " & $sIsUEFI[0]) ;~ MsgBox(0, "", "Supports64Bit: " & $sSupports64Bit) ;~ DllClose($dll) Exit ;~ $bIsUEFI = 0 ;~ $bIsUEFI = $oBDDUtility.IsUEFI ;~ $bIsAdmin = 0 ;~ $bIsAdmin = $oBDDUtility.IsAdmin ;~ $bIsHyperVirsorRunning = 0 ;~ $bIsHyperVirsorRunning = $oBDDUtility.IsHypervisorRunning ;~ $bSupportsNX = 0 ;~ $bSupportsNX = $oBDDUtility.SupportsNX ;~ $bSupportsVT = 0 ;~ $bSupportsVT = $oBDDUtility.SupportsVT ;~ $bSupports64Bit = 0 ;~ $bSupports64Bit = $oBDDUtility.Supports64Bit ;~ $bIs64Bit = 0 ;~ $bIs64Bit = $oBDDUtility.Is64Bit ;~ ConsoleWrite("UEFI: " & $bIsUEFI & @CRLF) ;~ ConsoleWrite("Is Admin: " & $bIsAdmin & @CRLF) ;~ ConsoleWrite("Is HyperVisor Running: " & $bIsHyperVirsorRunning & @CRLF) ;~ ConsoleWrite("Supports NX: " & $bSupportsNX & @CRLF) ;~ ConsoleWrite("Supports VT: " & $bSupportsVT & @CRLF) ;~ ConsoleWrite("Supports 64 Bit: " & $bSupports64Bit & @CRLF) ;~ ConsoleWrite("Is 64 Bit: " & $bIs64Bit & @CRLF) Can anyone help me understand where I'm going wrong with this? I did try searching the forums for answers first, but couldn't find anything related to this particular dll. Basically, I want to use this MDT dll to determine if the machine is running in UEFI or BIOS mode. Any help or advice is greatfully received! Many thanks, G. Edited July 31, 2013 by Gregor1806 Link to comment Share on other sites More sharing options...
JohnOne Posted July 31, 2013 Share Posted July 31, 2013 Have you registered the dll? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Gregor1806 Posted August 1, 2013 Author Share Posted August 1, 2013 (edited) OK, I played around with it a bit more and realised that my issues were related to OSArch. I've tested the snippet below and it all seems to work - albeit without using DllCall - as I couldn't get that to work. If anyone has time to explain how to achieve the same result as the below script using the native DllCall AutoIt command, I'd love to see how it is done (from a learning perspective) - but otherwise the following code is working fine for me (have tested it on W8 x64 and W7 x86). expandcollapse popup#RequireAdmin If @OSArch = "X86" Then #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** $sDllName = @ScriptDir & "\x86Microsoft.BDD.Utility.dll" ElseIf @OSArch = "X64" Then #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** $sDllName = @ScriptDir & "\x64Microsoft.BDD.Utility.dll" EndIf RunWait('regsvr32.exe /s "' & $sDllName & '"', "", @SW_HIDE) $oBDDUtility = ObjCreate("Microsoft.BDD.Utility") If @error Then MsgBox(0, "@Error", @error) Exit EndIf If IsObj($oBDDUtility) Then Local $bIsUEFI, $bIsAdmin, $bIsHyperVisorRunning, $bSupportsNX, $bSupportsVT, $bSupports64Bit, $bIs64Bit $bIsUEFI = $oBDDUtility.IsUEFI $bIsAdmin = $oBDDUtility.IsAdmin $bIsHyperVisorRunning = $oBDDUtility.IsHyperVisorRunning $bSupportsNX = $oBDDUtility.SupportsNX $bSupportsVT = $oBDDUtility.SupportsVT $bSupports64Bit = $oBDDUtility.Supports64Bit $bIs64Bit = $oBDDUtility.Is64Bit MsgBox(0, "Results", "UEFI: " & $bIsUEFI & @CRLF & _ "Is Admin: " & $bIsAdmin & @CRLF & _ "Is HyperVisor Running: " & $bIsHyperVisorRunning & @CRLF & _ "Supports NX: " & $bSupportsNX & @CRLF & _ "Supports VT: " & $bSupportsVT & @CRLF & _ "Supports 64 Bit: " & $bSupports64Bit & @CRLF & _ "Is 64 Bit: " & $bIs64Bit) EndIf RunWait('regsvr32.exe /s /u "' & $sDllName & '"', "", @SW_HIDE) Thanks, G. Edited August 1, 2013 by Gregor1806 Link to comment Share on other sites More sharing options...
JohnOne Posted August 1, 2013 Share Posted August 1, 2013 I don't think you have to register and unregister your dll each time. Just registering it once should do. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now