Sign in to follow this  
Followers 0
broodplank

AdminCount

3 posts in this topic

#1 ·  Posted (edited)

ok this is what i have but i want to make the loop working good, if i uncomment the loop and comment the ifs then it always shows the msgbox 10 times but it must only show it the times from 7 to $second

get it :whistle:?

#include <Process.au3>
#include <File.au3>

_AdminCount()


Func _AdminCount()

FileDelete("output.txt")
_RunDOS("net localgroup administrators >> output.txt")
$countline = _FileCountLines("output.txt")

;~ for $count = 10 to 20
;~ for $lines = 8 to 18

;~ if $countline = $count Then
;~  $second = $lines
;~  
;~ EndIf
;~ Next
;~ Next


if $countline = 8 Then 
    $second = 6
EndIf

if $countline = 9 Then 
    $second = 7
EndIf

if $countline = 10 Then 
    $second = 8
EndIf

if $countline = 11 Then 
    $second = 9
EndIf

if $countline = 12 Then 
    $second = 10
EndIf

if $countline = 13 Then 
    $second = 11
EndIf

if $countline = 14 Then 
    $second = 12
EndIf

if $countline = 15 Then 
    $second = 13
EndIf

if $countline = 16 Then 
    $second = 14
EndIf

if $countline = 17 Then 
    $second = 15
EndIf

if $countline = 18 Then 
    $second = 16
EndIf

if $countline = 19 Then 
    $second = 17
EndIf

if $countline = 20 Then 
    $second = 18
EndIf

for $i = 7 to $second
    $adminread = FileReadLine("output.txt", $i)
    MsgBox(0, "POSIBLE ADMINISTRATORS FOUND", $adminread)
Next
$admincount = MsgBox(64, "ADMIN COUNT", $second - 6)
FileDelete("output.txt")
EndFunc
Edited by broodplank

Share this post


Link to post
Share on other sites



Try this:

$admins = ""
$count = 0
$objGroup = ObjGet("WinNT://" & @ComputerName & "/Administrators")
For $objUser in $objGroup.Members
    $count += 1
    $admins &= $objUser.Name & @crlf
Next
msgbox(0,"Admins Found: " & $count, $admins)


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Or this is much faster:

#include <Constants.au3>

$foo = Run("net localgroup administrators", @SystemDir, @SW_HIDE, $STDOUT_CHILD)
$output = ""
While 1
    $output &= StdoutRead($foo)
    If @error Then ExitLoop
Wend
$aOutput = StringSplit($output,@crlf,1)

$admins = ""
$count = 0

$valid = false
for $i = 1 to $aOutput[0]
    $line = $aOutput[$i]
    if stringinstr($line,"The command") then $valid = false
    if $valid then
        $admins &= $line & @CRLF
        $count += 1
    EndIf
    if stringinstr($line,"----------") then $valid = true
Next

msgbox(0,"Admins Found: " & $count, $admins)


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0