Question Locked

force logoff after hours expire

0 helpful
19 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I've been trying to force users to logoff after their logon hours have expired through Group Policy. I have a SBS 2003 server and all workstations are running XP Pro. For some reason it is not working.

19 replies

by wancona

How do you test the group policy without interfering with productivity

by wancona

Does this just force them to work offline. I am looking for something that will shut every application down and log the individual out of the computer. I am having problems with people not remembering to log out at night, and certain scheduled task can not run because they are still logged in. Also, I can't keep going around to every computer at night to make sure the individual is logged out before I go home. So I need to insure that everyone is logged off before a particular time.

by scott_heath

I reread it and it only logs them off the server, not the local workstation. Should everyone be gone at a specific time? If so, write a script that kicks off from the server at a specific time and sends all stations a pop up message that they will be logged off in 5 minutes. Then 5 minutes later run a script that will log them off their PC or restart the PC.

by wancona

I read the link you gave me, and I realized too that it didn't logoff the computer, just disconnected the user from the network resources. It is a deceiving title "Fore logoff when hours expire"

by scott_heath

The suggestions by Paul and CG IT should do. I was hoping to find a way you could do it without scheduling a script, but oh well.

I would try to build in some logic that verifies the user has actually been logged off. Try it a few times and see how it goes. If you don't need 100% compliance every single night the shutdown command should work fine.

If you need 100% compliance let me know. Maybe we can work up a vbscript that uses WMI to check for logged on users and then only executes if they are logged on, checks to make sure it logged the user off, then takes more drastic measures if it isn't working.

by wancona

After doing research I've found that you pretty much have to run a batch file to actually force the user off the workstation. But I'm actually still in school, and I'm not too sure how to script a batch file. Is there anyone who can offer help?

by paul.cook

set a scheduled task on the workstations to run "shutdown -l -f -t 30" at a specific time
You can use the AT command to set scheduled tasks on remote computers.

Or create a batch file on the server and run it at 5:30pm or whenever:
shutdown -l -f -t 30 -m \\computer1
shutdown -l -f -t 30 -m \\computer2
....
or even better use the For command in a batch file to run another batch file on a text file list of computers.
complist.txt:
comp1
comp2.domain.com

logoffcomp.cmd:
shutdown -l -f -t 30 -m \\%1

logoffallcomps.cmd (this file is one line)
For /f %%a In (complist.txt) Do Call logoffcomp.cmd %%a

by cg it

that will close all applications, then shutdown the workstations.

there is also a command for providing a net message to users about a forced shutdown.

by wancona

Okay, if that is to shutdown the computers, is there a way to restart instead of shutdown. Because I really only need them to log off of the workstation so that Scheduled tasks can run in the middle of the night. If it shuts down, then it would defeat the purpose of the log off, and I would still have to go around and turn them back on by hand.

Don't want to seem unappreciative, That is very helpful information, but can it be tweaked to restart instead of shutdown, or just straight logg off?

by cmarcus

I thought that you couldn't use the -m switch with the -l switch?

by wancona

I've considered that. But the problem arises with the screen saver. If I set it too far off, it will not lock the computer during the working hours when they walk away from their systems. Because we deal with patient information, it has to lock during the day when they are idle, so as not to allow someone to walk up to the workstation and obtain patient information. Yet, if i set the screen saver, it will log them off throughout the day, and they could lose unsaved patient information.

Is there a way to schedule the screensavers to switch to different screensavers at different times? Similar to the way you can program cell phones to be set on a particular ringing theme at certain hours of the day.

by cg it

magic packet... or solar winds makes a whole suite of tools which shuts down and then restarts.

there's many tools on the web...

might ask another question on what are the best freeware or low cost tools for remote/force shutdown and restart.

by wancona

As I stated before, I am still a student, I was just fortunate enough to land a position in my field very early. I am very good at troubleshooting and pinpointing problems. But exactly how do you create a batch file, and should I execute it via Group Policy or go to each workstation and program it.

by churdoo

Use the -r switch in Paul's shutdown command above, means REBOOT instead of shutdown.

by wancona

I was able to create this script which will log off the computer workstation. I tired to post it before for others to use after tweaking it a little bit. But every time I tried, after I submitted it. It said thread unavailable, (on TechRepublics part). So I'll try again.

And thank you for the help.
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService. _
ExecNotificationQuery("Select * From __InstanceDeletionEvent " _
& "Within 1 Where TargetInstance ISA 'Win32_Process'")

Set objWMIService = GetObject("winmgmts:{(Shutdown)}\\" & _
strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")

For Each objItem in colItems
objItem.Win32Shutdown(0)
Next

This discussion is closed to new replies.