vatobeto Posted November 9, 2007 Share Posted November 9, 2007 (edited) Ok - no response on previous lamely-worded question. What I would like to know is: is there a way to access WMI (Windows Management Instrumentation) functions from AutoIt, as you can from Javascript? I need to enumerate the SIDs for all users in profile from a script. Is it possible for the admin in Vista to do this?V. Other script code looks like this:CODEOn Error Resume NextConst HKEY_LOCAL_MACHINE = &H80000002strComputer = "." Set objRegistry=GetObject("winmgmts:\\" & _ strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys For Each objSubkey In arrSubkeys strValueName = "ProfileImagePath" strSubPath = strKeyPath & "\" & objSubkey objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue Wscript.Echo strValueNextSource for above code: http://www.microsoft.com/technet/scriptcen...05/hey0603.mspx Edited November 9, 2007 by vatobeto Link to comment Share on other sites More sharing options...
vatobeto Posted November 9, 2007 Author Share Posted November 9, 2007 Ok - no response on previous lamely-worded question. What I would like to know is: is there a way to access WMI (Windows Management Instrumentation) functions from AutoIt, as you can from Javascript? I need to enumerate the SIDs for all users in profile from a script. Is it possible for the admin in Vista to do this?V. Other script code looks like this:CODEOn Error Resume NextConst HKEY_LOCAL_MACHINE = &H80000002strComputer = "." Set objRegistry=GetObject("winmgmts:\\" & _ strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys For Each objSubkey In arrSubkeys strValueName = "ProfileImagePath" strSubPath = strKeyPath & "\" & objSubkey objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue Wscript.Echo strValueNextSource for above code: http://www.microsoft.com/technet/scriptcen...05/hey0603.mspxBump. Nevermind.I found the beginning to the answer to my inquiry in a post by ArthurB in the thread: "How to explore wmi objects?, without knowing the attributs names"As follows:CODEFunc _EnumWMIclassInstances($classname, $servername = ".") Local $service = ObjGet("winmgmts:\\" & $servername & "\root\cimv2") Local $security = $service.Security_ $security.ImpersonationLevel = 3 Local $collection = $service.InstancesOf($classname) For $object In $collection For $property in $object.Properties_ ConsoleWrite($property.Name & ": " & $property.Value & @CR) Next NextEndFunc_EnumWMIclassInstances("Win32_Service")Thanks ArthurB. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 9, 2007 Share Posted November 9, 2007 Keep in mind that almost (not quite) anything you can do in VBScript can be done in AutoIt. Get your hands on the latest version of the MS Scriptomatic, which will show you VBScript code for almost anything in the automation interfaces, then translate what you need into AutoIt. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ResNullius Posted November 10, 2007 Share Posted November 10, 2007 Ok - no response on previous lamely-worded question. What I would like to know is: is there a way to access WMI (Windows Management Instrumentation) functions from AutoIt, as you can from Javascript? I need to enumerate the SIDs for all users in profile from a script. Is it possible for the admin in Vista to do this? V. This is an AutoIt script I adapted from a vbs script on http://windowsxp.mvps.org. Works on XP, I haven't tested on Vista. expandcollapse popup;based on "SIDlist.vbs by Ramesh Srinivasan, http://windowsxp.mvps.org #include <Array.au3> $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $AccountList = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_UserAccount", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $leftName = StringLeft($objItem.Name, 5) Switch $objItem.Name Case "HelpAssistant", "SUPPORT_388945a0", "ASPNET" ;exclude "special" built-in accounts" ContinueLoop Case $objItem.Disabled <> 0 ; exclude disabled accounts, comment out this and next line to include them ContinueLoop Case $leftName = "IUSR_" Or $leftName = "IWAM_" ;exclude more non-relevant accounts ContinueLoop Case Else $AccountList &= $objItem.Name & " = " & $objItem.SID & @CR EndSwitch Next Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_UserAccount") EndIf $AccountList = StringTrimRight($AccountList, 1) $aAccountList = StringSplit($AccountList, @CR) _ArrayDisplay($aAccountList) Link to comment Share on other sites More sharing options...
Klaatu Posted November 10, 2007 Share Posted November 10, 2007 Get your hands on the latest version of the MS Scriptomatic, which will show you VBScript code for almost anything in the automation interfaces, then translate what you need into AutoIt.Or, use Scriptomatic in AutoIt and you'll already have AutoIt code. My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! 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