vince76000 Posted August 11, 2006 Share Posted August 11, 2006 (edited) Sorry for my english, I'm french I don't know if this function already exits but i created one : Func WMI($strComputer,$Query) Dim $objLocator = ObjCreate("WbemScripting.SWbemLocator") dim $objService = $objLocator.ConnectServer($strComputer, "root\cimv2") Dim $Jobs = $objService.ExecQuery($Query) return $Jobs EndFunc An example for use it : This script send you all services names in a remote computer : Dim $Service Dim $string = "" Dim $table = WMI("127.0.0.1","SELECT * FROM Win32_Service") For $Service in $table $string = $string & " " & $Service.Name Next MsgBox(0, "Name: ", $string) Func WMI($strComputer,$Query) Dim $objLocator = ObjCreate("WbemScripting.SWbemLocator") dim $objService = $objLocator.ConnectServer($strComputer, "root\cimv2") Dim $table = $objService.ExecQuery($Query) return $table EndFunc regards Vincent Lassauce Edited August 12, 2006 by vince76000 Link to comment Share on other sites More sharing options...
vince76000 Posted August 11, 2006 Author Share Posted August 11, 2006 ALL CLASSES :http://www.dx21.com/SCRIPTING/WMI/classes.aspMicrosoft Link :http://msdn.microsoft.com/library/default....hrough_wmi_.asp Link to comment Share on other sites More sharing options...
Klaatu Posted August 11, 2006 Share Posted August 11, 2006 You pass $strComputer into your function, but then immediately set it to ".", which I believe is the current computer. So your function, given any remote computer name, would only return data from the current computer. Did you actually try getting data from a remote computer with this function, as written here? My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
vince76000 Posted August 11, 2006 Author Share Posted August 11, 2006 Did you actually try getting data from a remote computer with this function, as written here?you are right, that does not function I go found as to make my function and I go updated my message as fast as possible Sorry Link to comment Share on other sites More sharing options...
GaryFrost Posted August 11, 2006 Share Posted August 11, 2006 Suggest looking for Scriptomatic in this forum SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
olivertwistcoder Posted August 7, 2008 Share Posted August 7, 2008 I worked a little around this code and made this finally : #Include <date.au3> #include <file.au3> $log = FileOpen("softwarelist.txt", 2) FileWrite($log, "================================================" & @CRLF) FileWrite($log, "Software List " & @YEAR & "/" & @MON & "/" & @MDAY & " - at " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF) FileWrite($log, "================================================" & @CRLF & @CRLF) FileWrite($log, "------------------------------------------------------------------------------") Dim $Product Dim $string = "" Dim $table = WMI("127.0.0.1","SELECT * FROM Win32_Product") For $Product in $table $string = $string & @CRLF & "Description. " & $Product.Description & @CRLF & "Ver. " & $Product.Version & @CRLF & "Vendor. " & $Product.Vendor & @CRLF & "------------------------------------------------------------------------------" Next FileWrite($log, $string) FileWrite($log, @CRLF & @CRLF & "================================================" & @CRLF & "End of all treatments." & @CRLF & "================================================") FileClose($log) Func WMI($strComputer,$Query) Dim $objLocator = ObjCreate("WbemScripting.SWbemLocator") dim $objService = $objLocator.ConnectServer($strComputer, "root\cimv2") Dim $table = $objService.ExecQuery($Query) return $table EndFunc The includes were to add some requests to ini files in a first time. As date include. Anyway, the primary code was great. I just added some work around. Link to comment Share on other sites More sharing options...
weaponx Posted August 7, 2008 Share Posted August 7, 2008 (edited) Don't open old topics for no reason! AutoIt Scriptomatic generates WMI scripts for you. Edited August 7, 2008 by weaponx Link to comment Share on other sites More sharing options...
GEOSoft Posted August 7, 2008 Share Posted August 7, 2008 Don't open old topics for no reason! AutoIt Scriptomatic generates WMI scripts for you.Not to mention that it would be better if the function was Func WMI($Query, $strComputer = "localhost" ) There is also a link to the compiled version of ScriptoMatic in my sig. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
spudw2k Posted August 7, 2008 Share Posted August 7, 2008 (edited) Don't open old topics for no reason! AutoIt Scriptomatic generates WMI scripts for you.Just 'cause he created a script that does something that has been coded before (and it's not as robust) doen't mean he's opening an old topic; it's just his version of a UDF to perform WMI queries. I have done the same thing in my time and will post the code here when/if I find it.edit:By far - inferior to the scripto tool, but I like hands on.http://www.autoitscript.com/forum/index.ph...st&p=389577 Edited August 7, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
weaponx Posted August 7, 2008 Share Posted August 7, 2008 Just 'cause he created a script that does something that has been coded before (and it's not as robust) doen't mean he's opening an old topic; it's just his version of a UDF to perform WMI queries. I have done the same thing in my time and will post the code here when/if I find it.A quick search for Win32_Product reveals this has been covered many times. Link to comment Share on other sites More sharing options...
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