By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,127 Members | 1,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,127 IT Pros & Developers. It's quick & easy.

Tell if Win2000 or XP is inactive

P: n/a
Hello,

Auditors want us to log out a user if the computer they are logged onto
has been unused/inactive for a set period of time. It's trivial to
logout the user, but we're having trouble telling if the system is
indeed inactive. If we could learn that information, then we'd need to
measure how long it has been like this so we can all the logout
function. How might this determination and measurement be approached?

We're using Python 2.3.x w/o Mr. Hammonds extra Windows extensions. We
do not want to install the win32 extensions.

Thanks,
Bart
Jul 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Why not just use screensaver that begins after your
"unused/inactive" time period and check the On resume,
password protect" box (XP). They have to log back in to
do anything. Doesn't really log them "out", but if they
have applications loaded, logging them out is going to
be difficult (e.g. what do you do with any dialogs that
may appear asking about unsaved work) and may not be what
you really want. This should "protect" the unattended
machine (which is what the auditors want) and your users.

HTH,
Larry Bates
Syscon, Inc.

"Bart Nessux" <ba*********@hotmail.com> wrote in message
news:cd**********@solaris.cc.vt.edu...
Hello,

Auditors want us to log out a user if the computer they are logged onto
has been unused/inactive for a set period of time. It's trivial to
logout the user, but we're having trouble telling if the system is
indeed inactive. If we could learn that information, then we'd need to
measure how long it has been like this so we can all the logout
function. How might this determination and measurement be approached?

We're using Python 2.3.x w/o Mr. Hammonds extra Windows extensions. We
do not want to install the win32 extensions.

Thanks,
Bart

Jul 18 '05 #2

P: n/a

[Bart]
Auditors want us to log out a user if the computer they are logged onto
has been unused/inactive for a set period of time. It's trivial to
logout the user, but we're having trouble telling if the system is
indeed inactive. [...]

We're using Python 2.3.x w/o Mr. Hammonds extra Windows extensions. We
do not want to install the win32 extensions.


It's a bit weird to want to do Windows-specific things without installing
the win32 extensions. Would you be prepared to install ctypes and one extra
DLL? In that case I have a solution for you. If not, I don't believe it's
possible.

At http://www.codeproject.com/dll/trackuseridle.asp is an article on
tracking idle time. From the misleading-named "Download source files" link
you can download a zip file which includes IdleTrac.dll. Using ctypes you
can drive that DLL from Python like this:

---------------------------------------------------------------------------

import time
from ctypes import *

kernel32 = windll.kernel32
GetTickCount = kernel32.GetTickCount

# IdleTrac's API uses C++ mangled names. No bother.
IdleTrac = windll.IdleTrac
IdleTrackerInit = getattr(IdleTrac, "?IdleTrackerInit@@YAHXZ")
IdleTrackerTerm = getattr(IdleTrac, "?IdleTrackerTerm@@YAXXZ")
IdleTrackerGetLastTickCount = \
getattr(IdleTrac, "?IdleTrackerGetLastTickCount@@YAKXZ")

IdleTrackerInit()
for i in range(10):
idleDelta = float(GetTickCount() - IdleTrackerGetLastTickCount()) / 1000
print "Last input event was %.2f seconds ago." % idleDelta
time.sleep(1)
IdleTrackerTerm()

---------------------------------------------------------------------------

Hope that helps,

--
Richie Hindle
ri****@entrian.com

Jul 18 '05 #3

P: n/a
I suggested this as well... the auditors say no. They want the users
logged out. I may push for this again though.
Larry Bates wrote:
Why not just use screensaver that begins after your
"unused/inactive" time period and check the On resume,
password protect" box (XP). They have to log back in to
do anything. Doesn't really log them "out", but if they
have applications loaded, logging them out is going to
be difficult (e.g. what do you do with any dialogs that
may appear asking about unsaved work) and may not be what
you really want. This should "protect" the unattended
machine (which is what the auditors want) and your users.

HTH,
Larry Bates
Syscon, Inc.

"Bart Nessux" <ba*********@hotmail.com> wrote in message
news:cd**********@solaris.cc.vt.edu...
Hello,

Auditors want us to log out a user if the computer they are logged onto
has been unused/inactive for a set period of time. It's trivial to
logout the user, but we're having trouble telling if the system is
indeed inactive. If we could learn that information, then we'd need to
measure how long it has been like this so we can all the logout
function. How might this determination and measurement be approached?

We're using Python 2.3.x w/o Mr. Hammonds extra Windows extensions. We
do not want to install the win32 extensions.

Thanks,
Bart


Jul 18 '05 #4

P: n/a

[Richie]
Would you be prepared to install ctypes and one extra DLL?


Ah! I hadn't spotted that you were running on Win2000+. In that case you
can do it with ctypes alone:

---------------------------------------------------------------------------

import time
from ctypes import *

GetTickCount = windll.kernel32.GetTickCount
GetLastInputInfo = windll.user32.GetLastInputInfo

class LASTINPUTINFO(Structure):
_fields_ = [("cbSize", c_uint),
("dwTime", c_uint)]

lastInputInfo = LASTINPUTINFO()
lastInputInfo.cbSize = sizeof(lastInputInfo)
for i in range(10):
GetLastInputInfo(byref(lastInputInfo))
idleDelta = float(GetTickCount() - lastInputInfo.dwTime) / 1000
print "Last input event was %.2f seconds ago." % idleDelta
time.sleep(1)

---------------------------------------------------------------------------

--
Richie Hindle
ri****@entrian.com

Jul 18 '05 #5

P: n/a
The problem is that they don't always think all the way
through the implications of what they are asking you to
do. The workstation could have lots of "unsaved" work.
You can't just kill all the running applications, this
can have disastrous effects. You can't say yes to any
"Do you want to save your changes?" dialogs either.
It is even unclear what "idle" actually means. Does it
mean no keyboard/mouse activity in N minutes? What if
someone is running a long-running application, do you
kill the machine? With mail and other background apps
using CPU cycles in the background there's no way to tell
a long running accounting report from Outlook checking
for mail. Example: I have about 4-5 jobs set up in my
Windows scheduler that run unattended at night (Norton
Antivirus updates, pricelist downloads, etc). My
machine has normally been inactive for hours prior to
them running. If something logged me off the network
many of these jobs wouldn't run properly because they
need access to network resources. The screensaver solution
locks my machine to achieve security AND doesn't mess
with these background jobs.

Any solutions should take into account these possibilities.

Suggestion: I have seen a proximity badge that works with
Windows NT and above. If you walk away from the computer
too far, it triggers something forcing you to supply
a password for access. I don't remember the company, but
you should be able to Google for it. It would be expensive
I'm sure.

HTH,
Larry Bates
Syscon, Inc.
"Bart Nessux" <ba*********@hotmail.com> wrote in message
news:cd**********@solaris.cc.vt.edu...
I suggested this as well... the auditors say no. They want the users
logged out. I may push for this again though.
Larry Bates wrote:
Why not just use screensaver that begins after your
"unused/inactive" time period and check the On resume,
password protect" box (XP). They have to log back in to
do anything. Doesn't really log them "out", but if they
have applications loaded, logging them out is going to
be difficult (e.g. what do you do with any dialogs that
may appear asking about unsaved work) and may not be what
you really want. This should "protect" the unattended
machine (which is what the auditors want) and your users.

HTH,
Larry Bates
Syscon, Inc.

"Bart Nessux" <ba*********@hotmail.com> wrote in message
news:cd**********@solaris.cc.vt.edu...
Hello,

Auditors want us to log out a user if the computer they are logged onto
has been unused/inactive for a set period of time. It's trivial to
logout the user, but we're having trouble telling if the system is
indeed inactive. If we could learn that information, then we'd need to
measure how long it has been like this so we can all the logout
function. How might this determination and measurement be approached?

We're using Python 2.3.x w/o Mr. Hammonds extra Windows extensions. We
do not want to install the win32 extensions.

Thanks,
Bart


Jul 18 '05 #6

P: n/a
Larry Bates wrote:
The problem is that they don't always think all the way
through the implications of what they are asking you to
do. The workstation could have lots of "unsaved" work.
You can't just kill all the running applications, this
can have disastrous effects. You can't say yes to any
"Do you want to save your changes?" dialogs either.
It is even unclear what "idle" actually means. Does it
mean no keyboard/mouse activity in N minutes? What if
someone is running a long-running application, do you
kill the machine? With mail and other background apps
using CPU cycles in the background there's no way to tell
a long running accounting report from Outlook checking
for mail. Example: I have about 4-5 jobs set up in my
Windows scheduler that run unattended at night (Norton
Antivirus updates, pricelist downloads, etc). My
machine has normally been inactive for hours prior to
them running. If something logged me off the network
many of these jobs wouldn't run properly because they
need access to network resources. The screensaver solution
locks my machine to achieve security AND doesn't mess
with these background jobs.

Any solutions should take into account these possibilities.

Suggestion: I have seen a proximity badge that works with
Windows NT and above. If you walk away from the computer
too far, it triggers something forcing you to supply
a password for access. I don't remember the company, but
you should be able to Google for it. It would be expensive
I'm sure.

HTH,
Larry Bates
Syscon, Inc.
"Bart Nessux" <ba*********@hotmail.com> wrote in message
news:cd**********@solaris.cc.vt.edu...

I suggested this as well... the auditors say no. They want the users
logged out. I may push for this again though.
Larry Bates wrote:

Why not just use screensaver that begins after your
"unused/inactive" time period and check the On resume,
password protect" box (XP). They have to log back in to
do anything. Doesn't really log them "out", but if they
have applications loaded, logging them out is going to
be difficult (e.g. what do you do with any dialogs that
may appear asking about unsaved work) and may not be what
you really want. This should "protect" the unattended
machine (which is what the auditors want) and your users.

HTH,
Larry Bates
Syscon, Inc.

"Bart Nessux" <ba*********@hotmail.com> wrote in message
news:cd**********@solaris.cc.vt.edu...

Hello,

Auditors want us to log out a user if the computer they are logged onto
has been unused/inactive for a set period of time. It's trivial to
logout the user, but we're having trouble telling if the system is
indeed inactive. If we could learn that information, then we'd need to
measure how long it has been like this so we can all the logout
function. How might this determination and measurement be approached?

We're using Python 2.3.x w/o Mr. Hammonds extra Windows extensions. We
do not want to install the win32 extensions.

Thanks,
Bart



This could work?
http://aspn.activestate.com/ASPN/Coo...n/Recipe/52302

--
André Nobre
Jul 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.