Jump to content
Trolleule

Object Item not exists, how to catch error?

Recommended Posts

Trolleule

Hi,

when i try to access an object item, i get an error, but don't know how to catch this error:

 

Func GetFirewallRule($sName)
    Local $oPolicy = ObjCreate("HNetCfg.FwPolicy2")

    MsgBox(0, "test", $oPolicy.Rules.Item($sName)) ; throws error: The requested action with this object has failed.

EndFunc

Thanks in advance

Edited by Trolleule

Share this post


Link to post
Share on other sites
JLogan3o13
Func GetFirewallRule($sName)
    Local $oPolicy = ObjCreate("HNetCfg.FwPolicy2")
       If IsObj($oPolicy) Then
          MsgBox(0, "test", $oPolicy.Rules.Item($sName)) ; throws error: The requested action with this object has failed.
       Else
          ;Do Something Else
       EndIf
EndFunc

Hi, @Trolleule Look at IsObj in the help file.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Trolleule

Thanks...but it's not as easy as you think :D 

The problem, is that 

$oPolicy.Rules ; is always ok, but
$oPolicy.Rules.Item("Test") ; will throw error, if rule with name "Test" not exists

I already tried:

$oPolicy.Rules.Exists("Test")

but this property is not known in this context :(

Any ideas?

 

Edited by Trolleule

Share this post


Link to post
Share on other sites
mLipok

When you are using .....Item()

then you sould use ItemIndex instead name.

$oPolicy.Rules.Item(1))

 

Or other way like this:

GetFirewallRule('TeamViewer')

Func GetFirewallRule($sName)
    ; Error monitoring. This will trap all COM errors while alive.
    ; This particular object is declared as local, meaning after the function returns it will not exist.
    Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

    Local $oPolicy = ObjCreate("HNetCfg.FwPolicy2")

    Local $oRules_coll = $oPolicy.Rules
    If @error Then Return SetError(@error, @extended, '')

    For $oRule_enum In $oRules_coll
        If StringInStr($oRule_enum.name, $sName ) Then
        ConsoleWrite( $oRule_enum.name & @CRLF)
        EndIf
    Next

EndFunc    ;==>GetFirewallRule

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc    ;==>_ErrFunc

 

Some reference:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365322(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364724(v=vs.85).aspx


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites
Trolleule

yeah thats the solution i'm currently using, but only a workaround...i think.

thanks for your time mLipok! :) 

Quote

When you are using .....Item()

then you sould use ItemIndex instead name

see https://msdn.microsoft.com/en-us/library/aa365348(v=vs.85).aspx

Func FirewallRuleExists($sName)
    Local $oPolicy = ObjCreate("HNetCfg.FwPolicy2")
    Return (IsObj($oPolicy.Rules.Item($sName))) ? 1 : 0
EndFunc

The one liner is smarter, but i think it's not possible to catch this error with autoit, what do you mean?

Is there something to prevent autoit from crashing in this case?

 

EDIT:

ok i can catch it with  Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

but then every error will be catched. Is it possible to catch only error from the policy object and normal errors like syntax and so on will cause a crash?

Edited by Trolleule

Share this post


Link to post
Share on other sites
Trolleule

I did it like

Func FirewallRuleExists($sName)
    Local $oPolicy = ObjCreate("HNetCfg.FwPolicy2")
    Return (IsObj($oPolicy.Rules.Item($sName))) ? 1 : 0
EndFunc


Func Template_COMErrorRegister()
    $__g_oTemplateCOMErrorHandler = ObjEvent("AutoIt.Error", "Template_COMErrFunc")
EndFunc   ;==>Template_COMErrorRegister


Func Template_COMErrorUnregister()
    $__g_oTemplateCOMErrorHandler = 0
EndFunc   ;==>Template_COMErrorUnregister


Func Template_COMErrFunc()
    ; Do nothing special, just check @error after suspect functions.
EndFunc   ;==>Template_COMErrFunc

Func GetOutgoingTrafficRules()
    
    Template_COMErrorRegister()
    Local $aCurExplorerOptions[] = [ _
        FirewallRuleExists('"AADBrokerPlugin"-App') , _
        FirewallRuleExists('"AppAccountsControl"-App') , _
        FirewallRuleExists('"BioEnrollment"-App') , _
        FirewallRuleExists('"LockApp"') , _
        FirewallRuleExists('"Edge"-App (Teil 1/2)') , _
        FirewallRuleExists('"Edge"-App (Teil 2/2)') , _
        FirewallRuleExists('"AssignedAccessLockApp"-App') , _
        FirewallRuleExists('"Background Task Host"-Prozesses') , _
        FirewallRuleExists('"Download Upload Host"-Prozesses') , _
        FirewallRuleExists('"Hostprozesses für Windows-Aufgaben"') , _
        FirewallRuleExists('"Host Process for Setting Synchronization"') , _
        FirewallRuleExists('"Microsoft Compatibility Telemetry"-Prozesses') , _
        FirewallRuleExists('"FeedbackSIUFDeployment"-Prozesses') , _
        FirewallRuleExists('"Feeds Synchronization"-Prozesses') , _
        FirewallRuleExists('"MalwareProtectionCommandLineUtility"-Prozesses') , _
        FirewallRuleExists('"Windows-Tools zum Entfernen bösartiger Software"') , _
        FirewallRuleExists('"RuntimeBroker"-Prozesses') , _
        FirewallRuleExists('"SIH Client"-Prozesses') , _
        FirewallRuleExists('"Problem Reporting"-Prozesses') , _
        FirewallRuleExists('"SQM-Konsolidator"-Prozesses') , _
        FirewallRuleExists('"Windows-Aktivierungsclient"-Prozesses') , _
        FirewallRuleExists('"Device Association Framework Provider Host"-Prozesses') _
    ]
    Template_COMErrorUnregister()
    
    Return $aCurExplorerOptions
EndFunc

Not much better, but so i don't need to do an arraysearch for every rule :)

Share this post


Link to post
Share on other sites
mLipok
2 hours ago, Trolleule said:

see https://msdn.microsoft.com/en-us/library/aa365348(v=vs.85).aspx

Func FirewallRuleExists($sName)
    Local $oPolicy = ObjCreate("HNetCfg.FwPolicy2")
    Return (IsObj($oPolicy.Rules.Item($sName))) ? 1 : 0
EndFunc

 

"HNetCfg.FwPolicy2" is not the same as:
https://msdn.microsoft.com/en-us/library/aa365348(v=vs.85).aspx

"HNetCfg.FwPolicy2" is described here:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365322(v=vs.85).aspx

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites
Trolleule

yes but  "HNetCfg.FwPolicy2"  is/was not the problem...

Share this post


Link to post
Share on other sites
mLipok

So what is the problem ?


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites
Trolleule

oh you are right. So it have to be look like

Func FirewallRuleExists($sName)
    Local $oRules = ObjCreate("HNetCfg.FwRules")
    MsgBox(0, $oRules, VarGetType($oRulesy)) ; $oRules is 0 
    Return (IsObj($oRules.Item("Test"))) ? 1 : 0
EndFunc

but the object returns always 0. Do you know why?

Share this post


Link to post
Share on other sites
Danyfirex

Why not simply Return IsObj($oRules.Item("Test")) instead Return (IsObj($oRules.Item("Test"))) ? 1 : 0

 

Saludos

Share this post


Link to post
Share on other sites
Trolleule

shit thats right too @Danyfirex

i edited the code too much times, didn't see that :)

Strangely the object "HNetCfg.FwRules" can't be accessed. When i google for 

Quote

"HNetCfg.FwRules"

the results are always

Quote

"HNetCfg.FwRule"

which is not the same, but the documentation says this is a valid interface...no special remarks or something :S

Share this post


Link to post
Share on other sites
Trolleule

@mLipok now i got it -> it's the same, because

Quote

INetFwPolicy2.Rules( _
  ByRef rules, _
  ByRef rules _
) As INetFwRules

it returns a INetFwRules object...i know this shit is confusing :/

this explains why i can't access  "HNetCfg.FwRules" in this manner...

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

  • Similar Content

    • Bilgus
      By Bilgus
      ; NetFirewallPolicy2 COM UDF Library for AutoIt3
      ; AutoIt Version : 3.3.14.5
      ; Description ...: Windows Firewall Policy2 Interface, Provides access to the firewall policy for Windows Vista+
      Including Test Script 
      UDF:
      Test Script:
       
    • genius257
      By genius257
      I've made a library, based on AutoItObject UDF with the goal of implementing getter and setter functionality and make it possible to define new object properties in as few steps as possible.
      Thank you to @trancexx for getting me on the right track, and all users in Hooking into the IDispatch interface for the code to get me going.
      If I've forgotten to add credit, please let me know
      Example:
      #include "AutoItObject_Internal.au3" $myCar = IDispatch() $myCar.make = 'Ford' $myCar.model = 'Mustang' $myCar.year = 1969 $myCar.__defineGetter('DisplayCar', DisplayCar) Func DisplayCar($oThis) Return 'A Beautiful ' & $oThis.parent.year & ' ' & $oThis.parent.make & ' ' & $oThis.parent.model EndFunc MsgBox(0, "", $myCar.DisplayCar) More examples: https://github.com/genius257/AutoItObject-Internal/tree/master/Examples
      Version: 2.0.0
      AutoItObject_Internal.au3
      Documentation
      Edit2 (19th March 2017):
      First of all, sorry about the lack of updates on this project. I always start too many projects and end up ignoring old projects, if I run into problems ^^'.
      So I've started moving my AutoIt scripts to GitHub. I will still post the most recent script version here.
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      I'm working on a little project of mines, and I was trying to use WMI Object.
      The question which I don't find an answer is: 
      Once I do the query with WMI Object, something like "SELECT * FROM Win32_LogonSession", instead of specify the field of the collection returned, ( i.e. $colItems.Caption ), can I loop though each property and each value of the property, writing so one row of code only?
      Hope my question was clear enough.
      Thanks in advance.

      Best Regards.
    • Bilgus
      By Bilgus
      I was Playing around With AutoIt this evening and wondered how hard it would be to get typeinfo like the COM Viewers do only using AutoIt
      Turns out it was pretty easy.
      A Few Notes:
      CAarray info is unfinished I didn't have any objects to test it on so I left it Limited.
      The Object must have IDispatch exposed (ITypeInfo is derivative)
      Its Just a proof of concept Run with it but don't carry scissors
      ITypeInfoCOM.au3
      ITypeInfoTest.au3
       
      Output IWebBrowserApp
       
      Output ObjCreate(MediaPlayer.MediaPlayer.1)
       
    • Bilgus
      By Bilgus
       IGroupPolicyObject interface
      ;;IGroupPolicyObject #RequireAdmin #include-once #include <WinAPIConstants.au3> ; $S_OK #include <WinAPIReg.au3> ;_WinAPI_GetRegKeyNameByHandle Global Enum $GPO_SECTION_ROOT = 0x0, $GPO_SECTION_USER, $GPO_SECTION_MACHINE Global Enum $GPO_OPEN_LOAD_REGISTRY = 0x1, $GPO_OPEN_READ_ONLY Global Enum $GPO_OPTION_DISABLE_USER = 0x1, $GPO_OPTION_DISABLE_MACHINE Global Enum $GPOTypeLocal = 0x0, $GPOTypeRemote, $GPOTypeDS, $GPOTypeLocalUser, $GPOTypeLocalGroup Global Const $sCLSID_GroupPolicyObject = "{EA502722-A23D-11D1-A7D3-0000F87571E3}" Global Const $sIID_IGroupPolicyObject = "{EA502723-A23D-11D1-A7D3-0000F87571E3}" Global Const $dtag_IGroupPolicyObject = _ "New hresult(wstr;wstr;dword);" & _ ; Creates a new GPO in the Active Directory with the specified display name. "OpenDSGPO hresult(wstr;dword);" & _ ; Opens the specified GPO and optionally loads the registry information. "OpenLocalMachineGPO hresult(dword);" & _ ; Opens the default GPO for the computer and optionally loads the registry information. "OpenRemoteMachineGPO hresult(wstr;dword);" & _ ; Opens the default GPO for the specified remote computer and optionally loads the registry information. "Save hResult(bool;bool;ptr;ptr);" & _ ; Saves the specified registry policy settings to disk and updates the revision number of the GPO. "Delete hresult();" & _ ; Deletes the GPO. "GetName hResult(wstr;int);" & _ ; Retrieves the unique name for the GPO. "GetDisplayName hResult(wstr;int);" & _ ; Retrieves the display name for the GPO. "SetDisplayName hresult(wstr);" & _ ; Sets the display name for the GPO. "GetPath hResult(wstr;int);" & _ ; Retrieves the path to the GPO. "GetDSPath hresult(dword;wstr;int);" & _ ; Retrieves the Active Directory path to the root of the specified GPO section. "GetFileSysPath hresult(dword;wstr;int);" & _ ; Retrieves the file system path (UNC format) to the root of the specified GPO section. "GetRegistryKey hresult(dword;handle);" & _ ; Retrieves a handle to the root of the registry key for the specified GPO section. "GetOptions hResult(dword*);" & _ ; Retrieves the options for the GPO. "SetOptions hresult(dword;dword);" & _ ; Sets the options for the GPO. "GetType hResult(dword*);" & _ ; Retrieves type information for the GPO being edited. "GetMachineName hResult(wstr;int);" & _ ; Retrieves the computer name of the remote GPO. "GetPropertySheetPages hresult(ptr;uint*);" ; Retrieves the property sheet pages associated with the GPO. Test() Func Test() Local $iResult Local $oIGroupPolicy Local $aGpoType[5] = ["Local", "Remote", "Active Directory", "LocalUser", "LocalGroup"] $oIGroupPolicy = ObjCreateInterface($sCLSID_GroupPolicyObject, $sIID_IGroupPolicyObject, $dtag_IGroupPolicyObject) While True If Not IsObj($oIGroupPolicy) Then ConsoleWrite("Failed To Retrieve Interface") $iResult = $E_NOINTERFACE ExitLoop Else ConsoleWrite("Success: " & ObjName($oIGroupPolicy, 1) & @CRLF) EndIf Local $sLoc, $sPath, $sName, $iType $tKey = DllStructCreate("handle hKey") $iResult = $oIGroupPolicy.OpenLocalMachineGPO(BitOR($GPO_OPEN_LOAD_REGISTRY, $GPO_OPEN_READ_ONLY)) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetDisplayName($sLoc, 65535) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetName($sName, 65535) If $iResult <> $S_OK Then ExitLoop ConsoleWrite($sLoc & " : " & $sName & @CRLF) $iResult = $oIGroupPolicy.GetPath($sPath, 65535) If $iResult <> $S_OK Then ExitLoop $iResult = $oIGroupPolicy.GetType($iType) If $iResult <> $S_OK Then ExitLoop ConsoleWrite($sPath & @CRLF) $iResult = $oIGroupPolicy.GetType($iType) If $iResult <> $S_OK Then ExitLoop ConsoleWrite("Type: " & $aGpoType[$iType] & @CRLF) $iResult = $oIGroupPolicy.GetRegistryKey($GPO_SECTION_USER, DllStructGetPtr($tKey)) If $iResult <> $S_OK Then ExitLoop ConsoleWrite(_WinAPI_GetRegKeyNameByHandle(DllStructGetData($tKey, "hKey")) & @CRLF) ExitLoop WEnd Return SetError($iResult, 0, ($iResult = $S_OK)) EndFunc ;==>Test Note: Not well tested..
×