Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • August 25, 2016, 10:06:22 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: log users off at a certain time using task scheduler  (Read 4665 times)

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,007
    • View Profile
    • Donate to Member
log users off at a certain time using task scheduler
« on: January 27, 2008, 01:50:05 PM »
I have been trying to use the shutdown in a batch file to log a user off at a certain time but am having difficulties getting the switches right.  I am using shutdown -c-l 300 -m "Time restrictions are now forcing you to logoff in 5 minutes; please save all your work."  But the problem with this is it defaults to 60 seconds instead of 5 minutes.  It also grays out the option to cancel which is what I want.  If I reverse the c and l switch then it will do the 5 minutes but the cancel button is now active.  All I want it to do is log them off but this will shut the computer down instead. 

The l switch is suppose to log off only and if I remove the m switch then i cannot get the 5 minutes and it shutsdown.

Any ideas on how to fix this?  Maybe this could be a coding snack?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: log users off at a certain time using task scheduler
« Reply #1 on: January 27, 2008, 02:14:20 PM »
Now i'm confused... What OS do you have?

My win xp pro sp2 doesn't have the -m switch, and the -c switch is for adding a comment to the shutdown dialog...

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,007
    • View Profile
    • Donate to Member
Re: log users off at a certain time using task scheduler
« Reply #2 on: January 27, 2008, 02:26:32 PM »
I have XP SP2.  I downloaded the shutdown utility from Beyond Logic Shutdown http://www.beyondlog...hutdown/shutdown.htm

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: log users off at a certain time using task scheduler
« Reply #3 on: January 27, 2008, 04:20:08 PM »
Ok, now i understand.
It's a shame that the default "shutdown" utility that comes with windows doesn't allow you to logoff and have a timeout.

There are a few shutdown utilities that i'm sure are able to do this...

What exactly would you like to do? have the system display a message indicating that the computer will log of in X minutes, right?

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,007
    • View Profile
    • Donate to Member
Re: log users off at a certain time using task scheduler
« Reply #4 on: January 27, 2008, 05:02:47 PM »
that is correct.  I have set up restrictions using the net user routine but it won't log them off if they are already logged in.  So lets say I have "son" set to end at 9pm and would like for the logoff utiltiy to run at say 9:05pm and then in 5 minutes it would log him off at 9:10pm.

is this doable?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: log users off at a certain time using task scheduler
« Reply #5 on: January 27, 2008, 06:23:41 PM »
It sure is doable, so much so that it's done! :)

So, it only has 2 arguments (which are mandatory): timeout (in seconds) and message.

Example:
logoffin.exe 120 "the computer will logoff in 2 minutes"

There's a minor quirk: it won't log off until the messagebox is closed. As a workaround, i added a timeout of 30 seconds to the messagebox, thus, the minimum time that it guarantees the computer will be logged off is 30 seconds.

nite_monkey

  • Member
  • Joined in 2006
  • **
  • Posts: 727
    • View Profile
    • Just Plain Super
    • Read more about this member.
    • Donate to Member
Re: log users off at a certain time using task scheduler
« Reply #6 on: January 27, 2008, 06:33:58 PM »
using the program you mentioned(the beyond logic shutdown) try using shutdown -s logoff -l 300 -c -m "Time restrictions are now forcing you to logoff in 5 minutes; please save all your work."
[Insert really cool signature here]

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,007
    • View Profile
    • Donate to Member
Re: log users off at a certain time using task scheduler
« Reply #7 on: January 27, 2008, 07:05:14 PM »
thanks for the suggestions!  I will try them both and see how I like them.  Since the kids are now on that computer, I will have to wait to try it out.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,258
    • View Profile
    • Coding Snacks by Lanux128
    • Read more about this member.
    • Donate to Member
Re: log users off at a certain time using task scheduler
« Reply #8 on: January 27, 2008, 11:21:51 PM »
if you want more choices, take a look here. there are several tools mentioned.

CyberNotes: Remotely Restart & Shutdown Computers


MikeMcLoughlin

  • Supporting Member
  • Joined in 2007
  • **
  • default avatar
  • Posts: 31
    • View Profile
    • Donate to Member
Re: log users off at a certain time using task scheduler
« Reply #9 on: January 28, 2008, 04:22:14 AM »
I've found Shutter to be excellent.

http://www.den4b.com/

patthecat

  • Member
  • Joined in 2006
  • **
  • Posts: 88
    • View Profile
    • Donate to Member
Re: log users off at a certain time using task scheduler
« Reply #10 on: January 29, 2008, 07:03:27 PM »
I have used both
Shutter (http://www.den4b.com) and
PowerOff (http://users.pandora...an/applications.html)
Both utilities have the capability to LogOff a user as what you are looking for.

Currently at my niece&nephew's computer, I have task scheduler invoke a batch file calling PowerOff to shutdown the computer after 45 minutes of inactivity.  There's a 30 second message pop-up window warning of the shutdown.  The PowerOff specific command in the batch file I am using is:

start /min poweroff.exe shutdown -force -warn -warntime 30

You can add the "-nocancel" option to prevent the cancellation of the action from the warning message box or sys tray.

Patrick