Is there any way for AppleScript to see if no users are logged on? Thanks!
Hi,
yes, it is.
Remote Apple Events must be enabled in the Sharing PrefPane.
This routine doesn’t check the root user.
Maybe username and password is not necessary.
property user_name : "¢¢¢¢¢¢"
property pass_word : "¢¢¢¢¢¢"
set thisComputer to host name of (system info)
set allUsers to words of (do shell script "/usr/bin/nireport / /users name uid | grep \"5[0-9][0-9]\"")
set userCount to 0
set eppc to "eppc://" & user_name & ":" & pass_word & "@" & thisComputer & "/Finder?uid="
repeat with i from 1 to (count allUsers) / 2
set m to eppc & ((i + 500) as string)
using terms from application "Finder"
try
tell application m to get (desktop as string)
set userCount to userCount + 1
end try
end using terms from
end repeat
display dialog (userCount as string) & " user(s) logged in"
Quite clever!
I noticed that on a freshly installed OSX, the system warns you about logged-in users when sleeping or logging out.
(suggesting that somewhere deep inside, there should be another way to read this out)
Howewer, this functionality seems to magically disappear somehow (…) on the go
I know, Eelco, but I couldn’t find it (yet)
Sadly, this puppy seems broken.
It seems that /usr/bin/nireport is not on a fresh Leopard installation.
Would there be a fix…?
Thx
Of course, in Leopard use this
.
set allUsers to words of (do shell script "/usr/bin/dscl . -list /Users uid | /usr/bin/grep \"5[0-9][0-9]\"")
.
Stefan,
That’s super !
Does this also include remote AppleShare users, or is there a separate way to get those…?
Thx