Re: Force Logoff if Inactive
From: Torgeir Bakken (MVP) (Torgeir.Bakken-spam_at_hydro.com)
Date: Sun, 16 Nov 2003 03:38:59 +0100
Harry Paratestes wrote:
> Torgeir Bakken (MVP) wrote:
> > I don't know of any way with a script to determine idle time, but the
> > solution Steve suggested should work, creating a Scheduled Tasks on
> > every computer that kicks in after x minutes of idle time and runs a
> > logoff script/program.
> Just now I checked out the Scheduled Task Wizard on W2K client. I believe I
> could do what you're suggesting ..(snip)
I was able to to this now on a WinXP client using WinXP built in command line
task scheduler "manipulator" SCHTASKS.exe and the psshutdown.exe utility from
the free PSTools suite found at http://www.sysinternals.com.
This will create a scheduled task running with the credentials of the local
Administrator (with password xxx in the example) that logs the *console* user
off after 16,65 hours inactivity (999 minutes is the max value):
SCHTASKS.exe /Create /RU "%COMPUTERNAME%\Administrator" /RP xxx
/SC ONIDLE /I 999 /TN "IdleLogoff" /TR "C:\psshutdown.exe -o -f"
Note that the way this configures the task scheduler, if you set it to reboot
the computer it will reboot the computer even if nobody is logged in (when the
computer is idle at the logon screen). Logoff or shutdown/poweroff will be a
better choice I think.
Note that you can use SCHTASKS.exe to configure a scheduled task on a remote
computer (if that will work against a Win2k computer I do not know). Run
SCHTASKS /? in a command prompt for more help.
I was not able to use WinXP's shutdown.exe utility, it looks like it is not able
to log off another user than the one user that is defined as the "task" user.
However, Sysinternals's psshutdown utility was able to do this. I also tried to
use /RU "NT AUTHORITY\SYSTEM" instead of using the Administrator user, but I
could not get the scheduled task to run psshutdown.exe then.
For Win2k, it may be that JT.EXE is able to create a scheduled task like
SCHTASKS.exe is for WinXP:
-- torgeir Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter