bernie Posted March 14, 2007 Posted March 14, 2007 I'm trying to convert this vbs script to autoit. I used two different converter and had no luck. Can anyone please help me? strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48) For Each objItem in colItems Wscript.Echo objItem.Domain Next Thanks, Bernie
FeReNGi Posted March 14, 2007 Posted March 14, 2007 Output generated by Scriptomatic: expandcollapse popup; Generated by AutoIt Scriptomatic $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "AdminPasswordStatus: " & $objItem.AdminPasswordStatus & @CRLF $Output = $Output & "AutomaticResetBootOption: " & $objItem.AutomaticResetBootOption & @CRLF $Output = $Output & "AutomaticResetCapability: " & $objItem.AutomaticResetCapability & @CRLF $Output = $Output & "BootOptionOnLimit: " & $objItem.BootOptionOnLimit & @CRLF $Output = $Output & "BootOptionOnWatchDog: " & $objItem.BootOptionOnWatchDog & @CRLF $Output = $Output & "BootROMSupported: " & $objItem.BootROMSupported & @CRLF $Output = $Output & "BootupState: " & $objItem.BootupState & @CRLF $Output = $Output & "Caption: " & $objItem.Caption & @CRLF $Output = $Output & "ChassisBootupState: " & $objItem.ChassisBootupState & @CRLF $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF $Output = $Output & "CurrentTimeZone: " & $objItem.CurrentTimeZone & @CRLF $Output = $Output & "DaylightInEffect: " & $objItem.DaylightInEffect & @CRLF $Output = $Output & "Description: " & $objItem.Description & @CRLF $Output = $Output & "Domain: " & $objItem.Domain & @CRLF $Output = $Output & "DomainRole: " & $objItem.DomainRole & @CRLF $Output = $Output & "EnableDaylightSavingsTime: " & $objItem.EnableDaylightSavingsTime & @CRLF $Output = $Output & "FrontPanelResetStatus: " & $objItem.FrontPanelResetStatus & @CRLF $Output = $Output & "InfraredSupported: " & $objItem.InfraredSupported & @CRLF $strInitialLoadInfo = $objItem.InitialLoadInfo(0) $Output = $Output & "InitialLoadInfo: " & $strInitialLoadInfo & @CRLF $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF $Output = $Output & "KeyboardPasswordStatus: " & $objItem.KeyboardPasswordStatus & @CRLF $Output = $Output & "LastLoadInfo: " & $objItem.LastLoadInfo & @CRLF $Output = $Output & "Manufacturer: " & $objItem.Manufacturer & @CRLF $Output = $Output & "Model: " & $objItem.Model & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "NameFormat: " & $objItem.NameFormat & @CRLF $Output = $Output & "NetworkServerModeEnabled: " & $objItem.NetworkServerModeEnabled & @CRLF $Output = $Output & "NumberOfProcessors: " & $objItem.NumberOfProcessors & @CRLF $strOEMLogoBitmap = $objItem.OEMLogoBitmap(0) $Output = $Output & "OEMLogoBitmap: " & $strOEMLogoBitmap & @CRLF $strOEMStringArray = $objItem.OEMStringArray(0) $Output = $Output & "OEMStringArray: " & $strOEMStringArray & @CRLF $Output = $Output & "PartOfDomain: " & $objItem.PartOfDomain & @CRLF $Output = $Output & "PauseAfterReset: " & $objItem.PauseAfterReset & @CRLF $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0) $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF $Output = $Output & "PowerOnPasswordStatus: " & $objItem.PowerOnPasswordStatus & @CRLF $Output = $Output & "PowerState: " & $objItem.PowerState & @CRLF $Output = $Output & "PowerSupplyState: " & $objItem.PowerSupplyState & @CRLF $Output = $Output & "PrimaryOwnerContact: " & $objItem.PrimaryOwnerContact & @CRLF $Output = $Output & "PrimaryOwnerName: " & $objItem.PrimaryOwnerName & @CRLF $Output = $Output & "ResetCapability: " & $objItem.ResetCapability & @CRLF $Output = $Output & "ResetCount: " & $objItem.ResetCount & @CRLF $Output = $Output & "ResetLimit: " & $objItem.ResetLimit & @CRLF $strRoles = $objItem.Roles(0) $Output = $Output & "Roles: " & $strRoles & @CRLF $Output = $Output & "Status: " & $objItem.Status & @CRLF $strSupportContactDescription = $objItem.SupportContactDescription(0) $Output = $Output & "SupportContactDescription: " & $strSupportContactDescription & @CRLF $Output = $Output & "SystemStartupDelay: " & $objItem.SystemStartupDelay & @CRLF $strSystemStartupOptions = $objItem.SystemStartupOptions(0) $Output = $Output & "SystemStartupOptions: " & $strSystemStartupOptions & @CRLF $Output = $Output & "SystemStartupSetting: " & $objItem.SystemStartupSetting & @CRLF $Output = $Output & "SystemType: " & $objItem.SystemType & @CRLF $Output = $Output & "ThermalState: " & $objItem.ThermalState & @CRLF $Output = $Output & "TotalPhysicalMemory: " & $objItem.TotalPhysicalMemory & @CRLF $Output = $Output & "UserName: " & $objItem.UserName & @CRLF $Output = $Output & "WakeUpType: " & $objItem.WakeUpType & @CRLF $Output = $Output & "Workgroup: " & $objItem.Workgroup & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystem" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc ServicesPE|LoadVMDK
ptrex Posted March 14, 2007 Posted March 14, 2007 @ This is an other possibility. $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem") For $objItem in $colItems ConsoleWrite ($objItem.Domain & @CR) Next 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
bernie Posted March 14, 2007 Author Posted March 14, 2007 thanks for the help. this is what I end up with and it works great!!! $strComputer = @ComputerName $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem") For $objItem In $colItems $workgroup = $objItem.Domain Next MsgBox(1,"WorkGroup Name",$workgroup)
shx Posted March 14, 2007 Posted March 14, 2007 " Generated by AutoIt Scriptomatic" Does Scriptomatic also generate autoit code. I thought it was for vbs and jscript. thanks
Moderators SmOke_N Posted March 14, 2007 Moderators Posted March 14, 2007 " Generated by AutoIt Scriptomatic"Does Scriptomatic also generate autoit code.I thought it was for vbs and jscript.thankshttp://www.autoitscript.com/forum/index.ph...hl=ScriptoMatic Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
GEOSoft Posted March 14, 2007 Posted March 14, 2007 I'm trying to convert this vbs script to autoit. I used two different converter and had no luck. Can anyone please help me? strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48) For Each objItem in colItems Wscript.Echo objItem.Domain Next Thanks, Bernie$Computer = "." $Obj = ObjectGet("winmgmts:\\" & strComputer & "\root\cimv2") $Col = $Obj.ExecQuery("Select * from Win32_ComputerSystem",,48) For $ObjItem In $Col MsgBox(4096, "Result", $ObjItem.Domain) Next 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!"
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