Jens,
Okay I found the LoggedInUsers() UDF that you wrote. However, when I try to run it, it locks up.
My processor time goes to 99% and nothing happens. When I end the cmd screen, all my applications closes and the computer logs me off.
code:
;FUNCTION LOGGEDINUSERS()
;
;ACTION Retrieves a list of users/SIDs currently logged into the specified computer
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;VERSION 1.4 (cleaned up code, added error code return)
; 1.3 (removed dependency)
; 1.2
;
;DATE CREATED 2002/02/13
;
;DATE MODIFIED 2003/06/24
;
;KIXTART 4.20+
;
;SYNTAX ARRAY = LOGGEDINUSERS([COMPUTER])
;
;PARAMETERS COMPUTER
; Optional string specifying the remote computer to check, by default the local
; computer will be used to retrieve the list of users
;
;RETURN List of usernames/SIDs
;
;REMARKS Services that run under a specific user account will be returned, too. This function is
; not limited to interactive sessions.
;
;DEPENDENCIES none
;
;EXAMPLE $array = loggedinusers('WORKSTATION')
;
;KIXTART BBS http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000167
;
function loggedinusers(optional $computer)
Dim $regkey, $hivelist, $hive, $usersid, $username
Dim $userlist
$loggedinusers=''
$regkey='HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\HiveList'
if trim($computer)
$regkey='\\'+trim($computer)+'\'+$regkey
endif
if keyexist($regkey)
do
$hive=enumvalue($regkey,ubound($hivelist)+1)
if not @ERROR
redim preserve $hivelist[ubound($hivelist)+1]
$hivelist[ubound($hivelist)]=$hive
endif
until $hive=259 or @ERROR
for each $hive in $hivelist
if instr($hive,'\REGISTRY\USER') and not instr($hive,'\REGISTRY\USER\.DEFAULT')
$usersid=right($hive,len($hive)-instrrev($hive,'\'))
$username=sidtoname($usersid)
if $username=''
$username=$usersid
endif
if ascan($userlist,$username)=-1
redim preserve $userlist[ubound($userlist)+1]
$userlist[ubound($userlist)]=$username
endif
endif
next
endif
if ubound($userlist)+1
$loggedinusers=$userlist
endif
exit 0
endfunction
Any idea why?
Thanks