Jump to content

WMI help


Recommended Posts

Hi,

found the following VBS and want to use it to make a littel autoit script to use it.

The problem is I have no experience with WMI and autoit.

Took a look at some other scripts here but there are still too many questions.

It would be great, if someone here can help me with a few lines.

Thank you very much

Set oLocator = CreateObject("WbemScripting.SWbemLocator")

' --- Checking local WMI
WScript.Echo " Connect: root\CIMV2"
Set oWMIService = oLocator.ConnectServer("pcname", "root\CIMV2", "", "")

WScript.Echo "   Query: Select UUID from Win32_ComputerSystemProduct"
Set oWmiQuery = oWMIService.ExecQuery("Select UUID from Win32_ComputerSystemProduct")
For Each oUuid In oWmiQuery
                sUuid = oUuid.UUID
                WScript.Echo "Response: " & sUuid
                Exit For
Next
WScript.Echo ""
Link to comment
Share on other sites

Try

$oMyError = ObjEvent("AutoIt.Error","_MyErrFunc")

$oLocator = ObjCreate("WbemScripting.SWbemLocator")
; --- Checking local WMI
ConsoleWrite ( " Connect: root\CIMV2" & @Crlf )
$oWMIService = $oLocator.ConnectServer("pcname", "root\CIMV2", "", "")
ConsoleWrite ( "   Query: Select UUID from Win32_ComputerSystemProduct" & @Crlf )
$oWmiQuery = $oWMIService.ExecQuery("Select UUID from Win32_ComputerSystemProduct")
For $oUuid In $oWmiQuery
    $sUuid = $oUuid.UUID
    ConsoleWrite ( "Response : " & $sUuid & @Crlf )
    ExitLoop
Next

Func _MyErrFunc()
    $HexNumber=hex($oMyError.number,8)
    Msgbox(0,"???????? COM Error!",    ""& _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext )
    Exit
EndFunc

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Try this short variant:

Global $objItem, $UUID
Global $usr = ""
Global $pass = ""
Global $srv = "localhost"
Global $objWMILocator = ObjCreate("WbemScripting.SWbemLocator")
Global $objWMIService = $objWMILocator.ConnectServer($srv, "\root\cimv2", $usr, $pass, "", "", "&H80")
Global $colItems = $objWMIService.ExecQuery("SELECT UUID FROM Win32_ComputerSystemProduct", "WQL", 0x30)
If IsObj($colItems) Then
    For $objItem In $colItems
        $UUID = $objItem.UUID
    Next
    MsgBox(0, "UUID", $UUID)
EndIf

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

I have created on WMI script which will check the Bit locker status of the machine which needs the adminstrator rights... is there a way to check without admin rights? For your reference i have attached the VBS file along with this email.

Edited by Syed23

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

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