Jump to content

WMI Registry ReadString Error


Recommended Posts

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

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

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