DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

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

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,046
log users off at a certain time using task scheduler
« on: January 27, 2008, 07:50 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

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: log users off at a certain time using task scheduler
« Reply #1 on: January 27, 2008, 08:14 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,046
Re: log users off at a certain time using task scheduler
« Reply #2 on: January 27, 2008, 08:26 PM »
I have XP SP2.  I downloaded the shutdown utility from Beyond Logic Shutdown http://www.beyondlogic.org/solutions/shutdown/shutdown.htm

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: log users off at a certain time using task scheduler
« Reply #3 on: January 27, 2008, 10:20 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,046
Re: log users off at a certain time using task scheduler
« Reply #4 on: January 27, 2008, 11:02 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

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: log users off at a certain time using task scheduler
« Reply #5 on: January 28, 2008, 12:23 AM »
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: 753
Re: log users off at a certain time using task scheduler
« Reply #6 on: January 28, 2008, 12:33 AM »
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,046
Re: log users off at a certain time using task scheduler
« Reply #7 on: January 28, 2008, 01:05 AM »
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,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
Re: log users off at a certain time using task scheduler
« Reply #8 on: January 28, 2008, 05:21 AM »
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
  • **
  • Posts: 31
Re: log users off at a certain time using task scheduler
« Reply #9 on: January 28, 2008, 10:22 AM »
I've found Shutter to be excellent.

http://www.den4b.com/

patthecat

  • Member
  • Joined in 2006
  • **
  • Posts: 88
Re: log users off at a certain time using task scheduler
« Reply #10 on: January 30, 2008, 01:03 AM »
I have used both
Shutter (http://www.den4b.com) and
PowerOff (http://users.pandora.be/jbosman/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

Original address: https://www.donationcoder.com/forum/index.php?topic=12037.0