MSLx Fanboy Posted May 13, 2005 Share Posted May 13, 2005 ;;Comments below are the VBScript coding for enumerating all users on a local machine. ;;Currently the AutoIt Script works perfectly, except for that Filter statement (line 18). ;;It prints all devices in the "Wscript.Network" object, instead of filtering it by user ;;Your help would be greatly appreciated! #cs Set objNetwork = CreateObject("Wscript.Network") strComputer = objNetwork.ComputerName Set colAccounts = GetObject("WinNT://" & strComputer & "") colAccounts.Filter = Array("user") For Each objUser In colAccounts Wscript.Echo objUser.Name Next #ce $objNetwork = ObjCreate("Wscript.Network") $strComputer = $objNetwork.ComputerName $colAccounts = ObjGet("WinNT://" & @ComputerName) $colAccounts.Filter = "user" $return = IsObj($colAccounts) For $objUser In $colAccounts MsgBox(0, "test", $objUser.Name) Next It would be nice to figure this out, as I want to work on automation scripts for my school. I want to, in the future, enumerate all accounts, and check to see if there are any non-authorized accounts. Check to see if a certain account is disabled, check to see if hardware-acceleration for Dx9 is disabled, and various other things. As of now the school uses batch files, which are inheritely (sp?) insecure. Hopefully if I can get the Tech Staff to start using AutoIt, many of the script kiddies and hackers will stop taking advantage of the school network and our pipe to the Internet. Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted May 13, 2005 Author Share Posted May 13, 2005 Also, I'm looking at how to set a COM sub-object to another variable (i.e. $objUserFlags variable) Const $ADS_UF_DONT_EXPIRE_PASSWD = &h10000 $objUser = ObjGet("WinNT:// " & @ComputerName & "/Administrator ") $objUserFlags = ObjGet("",$objUser. & "UserFlags") $objPasswordExpirationFlag = $objUserFlags OR $ADS_UF_DONT_EXPIRE_PASSWD $objUser.Put "userFlags", $objPasswordExpirationFlag $objUser.SetInfo Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
JSThePatriot Posted May 13, 2005 Share Posted May 13, 2005 Also, I'm looking at how to set a COM sub-object to another variable (i.e. $objUserFlags variable)Const $ADS_UF_DONT_EXPIRE_PASSWD = &h10000 $objUser = ObjGet("WinNT:// " & @ComputerName & "/Administrator ") $objUserFlags = ObjGet("",$objUser. & "UserFlags") $objPasswordExpirationFlag = $objUserFlags OR $ADS_UF_DONT_EXPIRE_PASSWD $objUser.Put "userFlags", $objPasswordExpirationFlag $objUser.SetInfo<{POST_SNAPBACK}>Just something I saw quickly. I have yet to get into the COM world. Though my projects are propelling me in that direction at a quick rate.You may want to check the following code...;You have... $objUserFlags = ObjGet("",$objUser. & "UserFlags") ;It I think should be... $objUserFlags = ObjGet("",$objUser & ".UserFlags")Just as a side note have you tried in the above example to use "Users" instead of "users"? Just a thought.I hope that might help in some small way.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted May 13, 2005 Author Share Posted May 13, 2005 Yea, it took me a minute to realize that '.' thing...had to look back at the original several times to figure that out...I'm about to test the "User" thing. No go with the proper case, also tried adding an 's' to it as well. Attached the entire file I'm working on converting...accounts.au3 Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted May 14, 2005 Author Share Posted May 14, 2005 *bump* Any ideas? Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
JSThePatriot Posted May 15, 2005 Share Posted May 15, 2005 Okay... I have been searching for this while XP installs on a clients machine...(slow machine = couple of hours). So far this is what I have come up with.The Array("User") used by VBS is declaring the array. Some EvidenceHere is a code sample to show that infact the .filter "user" is an array. That is if my logic is correct.$objNetwork = ObjCreate("Wscript.Network") $strComputer = $objNetwork.ComputerName $colAccounts = ObjGet("WinNT://" & @ComputerName) ;$colAccounts = ObjGet("WinNT://" & $strComputer & "") $colAccounts1 = $colAccounts.Filter = IsArray("User") MsgBox(0, "Test", $colAccounts1)I then added this and got excited because I thought I figured it out.$objNetwork = ObjCreate("Wscript.Network") $strComputer = $objNetwork.ComputerName $colAccounts = ObjGet("WinNT://" & @ComputerName) ;$colAccounts = ObjGet("WinNT://" & $strComputer & "") $colAccounts1 = $colAccounts.Filter = IsArray("User") MsgBox(0, "Test", $colAccounts1) For $objUser In $colAccounts MsgBox(0, "test", $objUser.Name) NextThen I figured out why you want it filtered. :-/ I will continue to try to work on this but as of yet I have hit a dead end. I will try more on Monday. Might want to bump the topic again by then so I will notice it again in case I dont.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted May 15, 2005 Author Share Posted May 15, 2005 I pulled a UBound on it, and its returning 0. Go figure how it ISArray() but not UBound()'ing Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
JSThePatriot Posted May 15, 2005 Share Posted May 15, 2005 (edited) I dont know that is weird... Have you tried UBound(blah, 0 and 1 and 2)? Just to see? It might be that my logic is messed up and that it returns 1 for some odd weird reason. Surely there is a way to filter the data... JS EDIT: BTW I just got back from Orlando last weekend. Went down to see family. Love Florida :-P. I was 2 seconds from Disney... JS Edited May 15, 2005 by JSThePatriot AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
SvenP Posted May 15, 2005 Share Posted May 15, 2005 Hello, It's a known problem that COM 'Filter' methods did not like the way AutoIt arrays are organized. Today I finally got the time to take a better look at it. First of all I modified the COM code, so you have to wait until the beta version 3.1.1.31 has been released. Then, the correct code should be like this: $strComputer = @computerName $colAccounts = ObjGet("WinNT://" & $strComputer & "") Dim $User[1] $User[0]="User" $colAccounts.Filter = $User ; The Filter method accepts only Arrays For $objUser In $colAccounts ConsoleWrite($objUser.Name) Next When you want to Filter multiple types, then just add it to the array: Dim $User[2] $User[0]="User" $User[1]="Group" $colAccounts.Filter = $User ; This filters only users and groups As I said, you will have to wait for the new beta, before this works. Regards, -Sven Link to comment Share on other sites More sharing options...
PerryRaptor Posted May 15, 2005 Share Posted May 15, 2005 Cool! ADSI Windows NT NameSpace capability coming soon! Link to comment Share on other sites More sharing options...
PerryRaptor Posted May 15, 2005 Share Posted May 15, 2005 I tried version 3.1.1.31...Still cannot filter the namespace. Link to comment Share on other sites More sharing options...
SvenP Posted May 15, 2005 Share Posted May 15, 2005 I tried version 3.1.1.31...Still cannot filter the namespace.<{POST_SNAPBACK}>Try the sample code \tests\com\winntgroups.au3 that's included with the beta .ZIP version. That one works for sure. You can compare that sample script with yours to see where the differences are. Regards,-Sven Link to comment Share on other sites More sharing options...
PerryRaptor Posted May 15, 2005 Share Posted May 15, 2005 I get the same results. It looks like the array is displayed instead of filtered to user. Link to comment Share on other sites More sharing options...
JSThePatriot Posted May 16, 2005 Share Posted May 16, 2005 I get the same results. It looks like the array is displayed instead of filtered to user.<{POST_SNAPBACK}>If that is the case then the results are no different. I could get the array to display as shown above. Just need it to filter only the users.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
SvenP Posted May 16, 2005 Share Posted May 16, 2005 I get the same results. It looks like the array is displayed instead of filtered to user.<{POST_SNAPBACK}>I can't understand where the problem is:1. Does the unmodified winntgroups.au3 example not work?2. Does the filtering in YOUR script not work? If so, please upload your revised script.You ARE using at least Windows 2000, I hope.If you use a different operating system language, you might have to 'localize' the word 'user' or 'group' perhaps.Regards,-Sven Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted May 16, 2005 Author Share Posted May 16, 2005 (edited) winntgroups.au3 works, as does changing the array[0] variable to user. Thanks SvenP, that should hopefully make a majority of my scripts work now! (I'll have to wait to test on a machine with Admin access) Edited May 16, 2005 by MSLx Fanboy Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted May 16, 2005 Author Share Posted May 16, 2005 $strComputer = @ComputerName $colAccounts = ObjGet("WinNT://" & $strComputer & "") Is there a reason why it errors out if I put @ComputerName directly into the ObjGet() function? Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
SvenP Posted May 16, 2005 Share Posted May 16, 2005 $strComputer = @ComputerName $colAccounts = ObjGet("WinNT://" & $strComputer & "")Is there a reason why it errors out if I put @ComputerName directly into the ObjGet() function?<{POST_SNAPBACK}>I really don't know, the line:$colGroups = ObjGet("WinNT://" & @ComputerName ) Works perfectly well on my XP machine.Does your computername contain spaces or any special characters?-Sven Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted May 16, 2005 Author Share Posted May 16, 2005 (edited) MS KB Q228275 says that Computer Names cannot contain any of the following special characters /\[]":;|<>+=,?* _which includes a space. I'll try the script again, I have to run it by hand, not through SciTE, due to Au3Check issuesEdit: nevermind, I don't know what was going on. I'll keep testing and see if it happens again... Edited May 16, 2005 by MSLx Fanboy Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted May 17, 2005 Author Share Posted May 17, 2005 (edited) Another problem with another script $objUser = ObjGet("WinNT://" & @ComputerName & "/Matthew, user") MsgBox(0, "test", $objUser) ;;need to fix .SetPassword With $objUser .SetPassword = "testpassword" .SetInfo EndWith Errors on .SetPassword = ... Error function says "Member not found." Edited May 17, 2005 by MSLx Fanboy Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) 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