Re: Force Logoff if Inactive

From: Torgeir Bakken (MVP) (Torgeir.Bakken-spam_at_hydro.com)
Date: 11/16/03


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)

Hi

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:

http://www.jsiinc.com/SUBF/TIP2600/rh2621.htm
ftp://ftp.microsoft.com/reskit/win2000/jt.zip

--
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


Relevant Pages

  • Re: Configure a Scheduled Log-Off for Windows XP
    ... so it's not as simple as setting a policy on that computer. ... Psshutdown.exe in SysInternals's free PSTools suite does not suffer ... You can use SCHTASKS.exe to create the scheduled task, ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windowsxp.configuration_manage)
  • Re: Force Logoff if Inactive
    ... >> I don't know of any way with a script to determine idle time, ... This will create a scheduled task running with the credentials of the local ... Administrator that logs the *console* user ... Microsoft MVP Scripting and WMI, ...
    (microsoft.public.security)
  • Re: Force Logoff if Inactive
    ... >> I don't know of any way with a script to determine idle time, ... This will create a scheduled task running with the credentials of the local ... Administrator that logs the *console* user ... Microsoft MVP Scripting and WMI, ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Force Logoff if Inactive
    ... >> I don't know of any way with a script to determine idle time, ... This will create a scheduled task running with the credentials of the local ... Administrator that logs the *console* user ... Microsoft MVP Scripting and WMI, ...
    (microsoft.public.win2000.security)
  • Re: Run batch w/o log on
    ... enabled Wake the computer... ... > It does not run with administrator logged off. ... If you want to ensure the script has the same permissions as Administrator then make sure you specify the Administrator account and its correct login password in the security for the scheduled task. ...
    (microsoft.public.windowsxp.basics)