Jump to content
Sign in to follow this  

WMI help

Recommended Posts



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
WScript.Echo ""

Share this post

Link to post
Share on other sites


$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 )

Func _MyErrFunc()
    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 )

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

Share this post

Link to post
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
    MsgBox(0, "UUID", $UUID)



Edited by UEZ
  • Like 1

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post

Link to post
Share on other sites

Thanks a lot, I have tried the short version and it works fine.

Will later check the long version and try to learn a little bit about the code.

Thanks for the fast help.

Share this post

Link to post
Share on other sites


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]

Share this post

Link to post
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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.