SIMPLE_XP Posted October 26, 2007 Share Posted October 26, 2007 Ok, so I figured out how to create a new namespace in WMI... Func ADD_ROOT_NAMESPACE($PASSED_LOCAL_COMPUTER, $PASSED_NAMESPACE) Dim $OBJ_WMI_SERVICE, $OBJ_ITEM, $OBJ_NAME_SPACE $OBJ_WMI_SERVICE = ObjGet("winmgmts:\\" & $PASSED_LOCAL_COMPUTER & "\root") $OBJ_ITEM = $OBJ_WMI_SERVICE.Get("__Namespace") $OBJ_NAME_SPACE = $OBJ_ITEM.SpawnInstance_ $OBJ_NAME_SPACE.Name = $PASSED_NAMESPACE $OBJ_NAME_SPACE.Put_ EndFunc How do I now create Classes etc... and then write to them? Thanks in advance... Hero's Dawn, an RPG Adventure completely coded in AutoITwmifunctions UDF, WMI UDF Link to comment Share on other sites More sharing options...
SIMPLE_XP Posted October 29, 2007 Author Share Posted October 29, 2007 Anybody? Ok, so I figured out how to create a new namespace in WMI...Func ADD_ROOT_NAMESPACE($PASSED_LOCAL_COMPUTER, $PASSED_NAMESPACE) Dim $OBJ_WMI_SERVICE, $OBJ_ITEM, $OBJ_NAME_SPACE $OBJ_WMI_SERVICE = ObjGet("winmgmts:\\" & $PASSED_LOCAL_COMPUTER & "\root") $OBJ_ITEM = $OBJ_WMI_SERVICE.Get("__Namespace") $OBJ_NAME_SPACE = $OBJ_ITEM.SpawnInstance_ $OBJ_NAME_SPACE.Name = $PASSED_NAMESPACE $OBJ_NAME_SPACE.Put_EndFuncHow do I now create Classes etc... and then write to them? Thanks in advance... Hero's Dawn, an RPG Adventure completely coded in AutoITwmifunctions UDF, WMI UDF Link to comment Share on other sites More sharing options...
doudou Posted October 29, 2007 Share Posted October 29, 2007 Not knowing what exactly you are trying to achieve, I can give you an example how to access services and processes on some machine. $strComputer = "localhost" $wmiLocator = ObjCreate("WbemScripting.SWbemLocator") $wmiService = $wmiLocator.ConnectServer($strComputer, "root\cimv2", "user", "password") $colServices = $wmiService.ExecQuery("Select * from Win32_Service") ; enumerate windows services and start Scheduler For $objService in $colServices ConsoleWrite($objService.Name & ": " & $objService.DisplayName & " (" & $objService.State & ")") If $objService.Name = "Scheduler" Then $objService.StartService() Next ; select running notepad and kill it $colProcess = $wmiService.ExecQuery("Select * from Win32_Process Where Name = 'Notepad.exe'") For $objProcess in $colProcess ConsoleWrite($objProcess.Name & ": " & $objProcess.ExecutablePath) $objProcess.Terminate() Next UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE Link to comment Share on other sites More sharing options...
SIMPLE_XP Posted October 29, 2007 Author Share Posted October 29, 2007 Thanks for replying, but I know how to read from WMI, I am trying to figure out how to write to WMI (In the namespace I created with the posted code) without an intermediary providor. Is this possible in AutoIT? Not knowing what exactly you are trying to achieve, I can give you an example how to access services and processes on some machine. $strComputer = "localhost" $wmiLocator = ObjCreate("WbemScripting.SWbemLocator") $wmiService = $wmiLocator.ConnectServer($strComputer, "root\cimv2", "user", "password") $colServices = $wmiService.ExecQuery("Select * from Win32_Service") ; enumerate windows services and start Scheduler For $objService in $colServices ConsoleWrite($objService.Name & ": " & $objService.DisplayName & " (" & $objService.State & ")") If $objService.Name = "Scheduler" Then $objService.StartService() Next ; select running notepad and kill it $colProcess = $wmiService.ExecQuery("Select * from Win32_Process Where Name = 'Notepad.exe'") For $objProcess in $colProcess ConsoleWrite($objProcess.Name & ": " & $objProcess.ExecutablePath) $objProcess.Terminate() Next Hero's Dawn, an RPG Adventure completely coded in AutoITwmifunctions UDF, WMI UDF Link to comment Share on other sites More sharing options...
SIMPLE_XP Posted October 29, 2007 Author Share Posted October 29, 2007 Ok, I think I figured it out... (found some cool stuff in vbscript) I will post the code as soon as I have it validated. I am sure someone else will want to know how to do this in AutoIT as well. Maybe I will make WMI UDF if I have time. Thanks for replying, but I know how to read from WMI, I am trying to figure out how to write to WMI (In the namespace I created with the posted code) without an intermediary providor. Is this possible in AutoIT? Hero's Dawn, an RPG Adventure completely coded in AutoITwmifunctions UDF, WMI UDF Link to comment Share on other sites More sharing options...
ptrex Posted October 29, 2007 Share Posted October 29, 2007 @SIMPLE_XP I am interested at least to see what It can contribute. Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
SIMPLE_XP Posted October 31, 2007 Author Share Posted October 31, 2007 (edited) Sorry it took so long... I have been busy at work. I created a basic wmifunctions.au3 UDF.Here is the lowdown: Create a new namespace in the rootDelete a namespace in the rootAdd a Class, set the key property and add additional propertiesIt is Beta, so please do not make fun! I will add some additional functionality in the future. Example of how to use the functions:CODE#include <wmifunctions.au3>$LOCAL_COMPUTER = "."$NAME_SPACE = "AutoIT"$CLASS = "WMIisFun"$KEYPROPERTY = "KeyProperty,False"$PROPERTYLIST = "FirstProperty,False|SecondProperty,False|ThirdProperty,False"_ADD_ROOT_NAMESPACE($LOCAL_COMPUTER, $NAME_SPACE)_CREATE_NAMESPACE_CLASS($LOCAL_COMPUTER, $NAME_SPACE, $CLASS, $KEYPROPERTY, $PROPERTYLIST)_DELETE_NAMESPACE($LOCAL_COMPUTER, $NAME_SPACE)wmifunctions.au3 Edited October 31, 2007 by SIMPLE_XP Hero's Dawn, an RPG Adventure completely coded in AutoITwmifunctions UDF, WMI UDF 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