Sign in to follow this  
Followers 0
UEZ

[Solved] Problem with ObjGet()

5 posts in this topic

#1 ·  Posted (edited)

I got a system where I get the em:

Line -1:

Error: The requested action with this object has failed.

although IsObj() is true!

Here a snippet:

$HKLM = 0x80000002
    $BaseKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\"
    $objReg = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $srv & "\root\default:StdRegProv")
    If IsObj($objReg) Then
        $objReg.GetStringValue($HKLM, $BaseKey, "Test", $OS_Test)
    EndIf

When I use Scriptomatic against the system no information will be sent back (each value is empty)!

I want to avoid that my script is terminating with an em and I don't want use RegRead()!

Has somebody an idea for a workaround?

Thanks,

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

Share this post


Link to post
Share on other sites



You need something like this:

Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")

$HKLM = 0x80000002
$srv = "localhost"
$BaseKey = ""
$OS_Test = ""
$BaseKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\"
$objReg = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $srv & "\root\default:StdRegProv")
If IsObj($objReg) Then
    $objReg.GetStringValueq($HKLM, $BaseKey, "Test", $OS_Test)
EndIf



Func _ErrFunc()
    Return
EndFunc

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

You need something like this:

Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")

$HKLM = 0x80000002
$srv = "localhost"
$BaseKey = ""
$OS_Test = ""
$BaseKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\"
$objReg = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $srv & "\root\default:StdRegProv")
If IsObj($objReg) Then
    $objReg.GetStringValueq($HKLM, $BaseKey, "Test", $OS_Test)
EndIf



Func _ErrFunc()
    Return
EndFunc

Thanks a lot trancexx! Working as expected! We simple solution. ;)

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: Just to clarify; did you notice it had nothing to do with IsObj()? You had an object, and it failed to do something, which lead to "Error: The requested action with this object has failed.". What trancexx gave you was error handling to silently deal with the error.

If for some reason you tried $objReg.GetStringValueq() when $objReg is not an object, the message would have been 'Variable must be of type "Object".'

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

@UEZ: Just to clarify; did you notice it had nothing to do with IsObj()? You had an object, and it failed to do something, which lead to "Error: The requested action with this object has failed.". What trancexx gave you was error handling to silently deal with the error.

If for some reason you tried $objReg.GetStringValueq() when $objReg is not an object, the message would have been 'Variable must be of type "Object".'

;)

PsaltyDS,

the issue is that I use the code from my 1st post (only a snippet) to read a value from the registry of a remote system. I don't know the reason why communication is not working properly. When I use Scriptomatic it gives me nothing back! I assume that the WMI service is not working properly on the remote system or the system it too busy (restart of the service or better restart of the system will probably solve the problem).

My goal is that such kind of circumstances will not terminate the script and trancexx' idea (I don't know why I didn't catch that because it is not unknown to me) is what I searched for.

Thanks for your comment.

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

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