#116069 - 2004-03-12 04:23 PM
Re: Output without error 0
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
$nul=RedirectOutput("domainusers.log")
|
|
Top
|
|
|
|
#116070 - 2004-03-12 04:28 PM
Re: Output without error 0
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Try this instead...
Code:
$domain = GetObject("WinNT://"+@Domain) $nul=RedirectOutput("domainusers.log") For Each $object in $domain If $object.class = "user" ? $object.name Endif Next
You were getting a 0 because you were not trapping the return code from the RedirectOutput function. Notice I added a $nul= to the front of it so that the return code of 0 is now sent to the $nul variable and not to the console. I also moved the RedirectOutput outside of the For Next loop since you only have to specify it once. You code was also returning groups as well as users so I added the .class If Endif portion to be sure it only logs users.
|
|
Top
|
|
|
|
#116071 - 2004-03-12 04:43 PM
Re: Output without error 0
|
otf
Getting the hang of it
Registered: 2003-11-21
Posts: 53
Loc: Scotland
|
many thanks, man you guys are quick  i'm new to KiX but i'm learning fast i'll give it a try cheers!
|
|
Top
|
|
|
|
#116072 - 2004-03-12 04:44 PM
Re: Output without error 0
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Even better: Code:
If RedirectOutput("domainusers.log",1) "Whoops! Cannot open the output log!" ? "Error "+@ERROR+": "+@SERROR ? EndIf $domain = GetObject("WinNT://"+@Domain) For Each $object in $domain If $object.class = "user" ? $object.name EndIf Next
Error return values are usually (although not always) worth checking. If you don't, they'll bite you in the bum later.
|
|
Top
|
|
|
|
#116075 - 2004-03-12 08:56 PM
Re: Output without error 0
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
Quote:
You code was also returning groups as well as users so I added the .class If Endif portion to be sure it only logs users.
he was on the right track with the
$domain.filter = "user"
but the .filter object needs an array passed to it for it to work.
$domain.filter = "user",""
or
$domain.filter = split("user")
will give .filter the needed array value for it to work.
Edited by Bryce (2004-03-12 09:00 PM)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 764 anonymous users online.
|
|
|