DonationCoder.com Forum

Main Area and Open Discussion => Living Room => Topic started by: techidave on January 27, 2008, 01:50 PM

Title: log users off at a certain time using task scheduler
Post by: techidave on January 27, 2008, 01: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?
Title: Re: log users off at a certain time using task scheduler
Post by: jgpaiva on January 27, 2008, 02: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...
Title: Re: log users off at a certain time using task scheduler
Post by: techidave on January 27, 2008, 02:26 PM
I have XP SP2.  I downloaded the shutdown utility from Beyond Logic Shutdown http://www.beyondlogic.org/solutions/shutdown/shutdown.htm
Title: Re: log users off at a certain time using task scheduler
Post by: jgpaiva on January 27, 2008, 04: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?
Title: Re: log users off at a certain time using task scheduler
Post by: techidave on January 27, 2008, 05: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?
Title: Re: log users off at a certain time using task scheduler
Post by: jgpaiva on January 27, 2008, 06:23 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.
Title: Re: log users off at a certain time using task scheduler
Post by: nite_monkey on January 27, 2008, 06:33 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."
Title: Re: log users off at a certain time using task scheduler
Post by: techidave on January 27, 2008, 07:05 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.
Title: Re: log users off at a certain time using task scheduler
Post by: lanux128 on January 27, 2008, 11:21 PM
if you want more choices, take a look here (http://cybernetnews.com/2008/01/24/cybernotes-remotely-restart-shutdown-computers/). there are several tools mentioned.

• CyberNotes: Remotely Restart & Shutdown Computers (http://cybernetnews.com/2008/01/24/cybernotes-remotely-restart-shutdown-computers/)

Title: Re: log users off at a certain time using task scheduler
Post by: MikeMcLoughlin on January 28, 2008, 04:22 AM
I've found Shutter to be excellent.

http://www.den4b.com/
Title: Re: log users off at a certain time using task scheduler
Post by: patthecat on January 29, 2008, 07:03 PM
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