Force logoff at a particular time

Man, I haven’t posted in ages! Well, here’s something I want to remember for later. Force a computer to logoff at a particular time, but still allow logons later. Using Active Directory, I think, will force a logon schedule and dissallow users from logon if not within scheduled times.

On the computer you want to force logoff, open the C: drive and create a text file. Then rename it to, force-logoff.bat
Be sure you can view the extensions, or it will hide the .txt at the end and this wont work. (it can’t be force-logoff.bat.txt, which is what you’ll get if you have “hide extensions of known file types” selected)
Then right click, edit.
Put this in the file and save it.

PsShutdown.exe -o -f

After that, find PsShutdown.exe and copy/paste it into the C:\Windows dir on that system. Get it from here:
You’ll have to unzip that and get the Psshutdown tool out of it.  I usually just put all the Pstools in the Windows directory anyway, it’s handy to have.
Then to test, just double click the force-logoff.bat file and it should log you out.  NOTE: The first time you run any of the PSTools, you’ll get a little EULA and you’ll need to agree to the terms.  Not big deal, then after that you won’t get a popup.

Last, make a schedule for it to run every day at your desired time.

Here’s the link to the Microsoft site regarding PsShutdown command line usage.