Sign in to follow this  
Followers 0
FreakyMonkey

WMI Registry ReadString Error

5 posts in this topic

Func getPPVersion($ip)
if not Ping($ip,1000) Then
  return "Offline"
EndIf
local $strWMI = "winmgmts:{impersonationLevel=Impersonate}!\\" & $ip & "\Root\default:StdRegProv"
local $objWMIService = ObjGet($strWMI)
if not IsObj($objWMIService) then return "Unknown"
 
local $strKeyPath = "\Software\Tamtron\PowerPath Client\Install Info"
local $strKeyValueName = "Version"
local $strKeyValue
$objWMIService.GetStringValue($HKEY_LOCAL_MACHINE, $strKeyPath, $strKeyValueName, $strKeyValue)
if @error Then
  return ""
Else
  return $strKeyValue
EndIf
EndFunc

I'm getting this error:

\\cel-fil-001\profiles$\eleaf\Desktop\GetSLSCWorkstationsDameware.au3 (92) : ==> The requested action with this object has failed.:

$objWMIService.GetStringValue($HKEY_LOCAL_MACHINE, $strKeyPath, $strKeyValueName, $strKeyValue)

$objWMIService.GetStringValue($HKEY_LOCAL_MACHINE, $strKeyPath, $strKeyValueName, $strKeyValue)^ ERROR

Share this post


Link to post
Share on other sites



LOL ok. but thanks for the reply anyway.

Share this post


Link to post
Share on other sites

Try this:

Global $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler")

MsgBox(0, "Test", WMI_GetRegKey("."))

Func WMI_GetRegKey($host)
    If $host = "." Then $host = @ComputerName
    Local $ping = Ping($host, 1000)
    If @error Then Return SetError(1, 0, -1)
    Local $objReg = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $host & "\root\default:StdRegProv")
    If @error Then Return SetError(2, 0, -2)
    If IsObj($objReg) Then
        Local $HKLM = 0x80000002
        Local $strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\"
        Local $strKeyValueName = "Shell"
        Local $strKeyValue
        $objReg.GetStringValue($HKLM, $strKeyPath, $strKeyValueName,  $strKeyValue)
        Return $strKeyValue
    Else
        Return SetError(3, 0, -3)
    EndIf
EndFunc

Func ObjErrorHandler()
     ConsoleWrite(  "A COM Error has occured!" & @CRLF  & @CRLF & _
                                "err.description is: "    & @TAB & $oErrorHandler.description    & @CRLF & _
                                "err.windescription:"     & @TAB & $oErrorHandler & @CRLF & _
                                "err.number is: "         & @TAB & Hex($oErrorHandler.number, 8)  & @CRLF & _
                                "err.lastdllerror is: "   & @TAB & $oErrorHandler.lastdllerror   & @CRLF & _
                                "err.scriptline is: "     & @TAB & $oErrorHandler.scriptline     & @CRLF & _
                                "err.source is: "         & @TAB & $oErrorHandler.source         & @CRLF & _
                                "err.helpfile is: "       & @TAB & $oErrorHandler.helpfile       & @CRLF & _
                                "err.helpcontext is: "    & @TAB & $oErrorHandler.helpcontext & @CRLF _
                            )
EndFunc

#cs
Func getPPVersion($ip)
    if not Ping($ip,1000) Then
      return "Offline"
    EndIf
    local $strWMI = "winmgmts:{impersonationLevel=Impersonate}!\\" & $ip & "\Root\default:StdRegProv"
    local $objWMIService = ObjGet($strWMI)
    if not IsObj($objWMIService) then return "Unknown"

    local $strKeyPath = "\Software\Tamtron\PowerPath Client\Install Info"
    local $strKeyValueName = "Version"
    local $strKeyValue
    $objWMIService.GetStringValue($HKEY_LOCAL_MACHINE, $strKeyPath, $strKeyValueName, $strKeyValue)
    if @error Then
      return ""
    Else
      return $strKeyValue
    EndIf
EndFunc
#ce

Br,

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

Share this post


Link to post
Share on other sites

UEZ,

Thanks for the reply. Although your resolution did work, it was due to your constant declaration of HKLM cluing me into the fact I had used the wrong value. I had the VBS value of H80000002 rather than 0x80000002 in my constant.

Thanks ^.^

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  
Followers 0