rajeshontheweb Posted December 20, 2009 Posted December 20, 2009 (edited) here is my situation i have an object (actually wmi object) Func TestFunction($Parameter) Dim $wbemFlagReturnImmediately = 0x10 Dim $wbemFlagForwardOnly = 0x20 Dim $colItems = "" Dim $strComputer = "localhost" Dim $retVal = 0 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM win32_computersystemproduct", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $retVal = "Caption: " & $objItem.UUID ; <<<<<<<<<<<<<<<<<<<<<<<<<<------------------ Next EndIf Return $retVal EndFunc ;==>TestFunction ConsoleWrite(@CRLF & TestFunction("UUID") & @CRLF) Now, In place of calling TestFunction("UUID") if i say "Name" it should execute the line as $objItem.Name i.e., TestFunction("UUID") <--> $retVal = "Caption: " & $objItem.UUID TestFunction("Name") <--> $retVal = "Caption: " & $objItem.Name Edited December 20, 2009 by rajeshontheweb Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet
Authenticity Posted December 20, 2009 Posted December 20, 2009 ConsoleWrite(TestFunction("UUID") & @CRLF) ConsoleWrite(TestFunction("Name") & @CRLF) Func TestFunction($Parameter) Dim $wbemFlagReturnImmediately = 0x10 Dim $wbemFlagForwardOnly = 0x20 Dim $colItems = "" Dim $strComputer = "localhost" Dim $retVal = 0 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM win32_computersystemproduct", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $retVal = "Caption: " & Execute("$objItem." & $Parameter) ; <<<<<<<<<<<<<<<<<<<<<<<<<<------------------ Next EndIf Return $retVal EndFunc ;==>TestFunction
taurus905 Posted January 17, 2010 Posted January 17, 2010 ConsoleWrite(TestFunction("UUID") & @CRLF) ConsoleWrite(TestFunction("Name") & @CRLF) Func TestFunction($Parameter) Dim $wbemFlagReturnImmediately = 0x10 Dim $wbemFlagForwardOnly = 0x20 Dim $colItems = "" Dim $strComputer = "localhost" Dim $retVal = 0 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM win32_computersystemproduct", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $retVal = "Caption: " & Execute("$objItem." & $Parameter) ; <<<<<<<<<<<<<<<<<<<<<<<<<<------------------ Next EndIf Return $retVal EndFunc ;==>TestFunction Hello Authenticity, That is a nice solution and one I have been using. But I was wondering if there is an alternative to using the "Execute" function, as in the following line: $retVal = "Caption: " & Execute("$objItem." & $Parameter) ; Many thanks to anyone who can enlighten me. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now